Validation unit tests updated.
This commit is contained in:
parent
64b37cd4eb
commit
641bf1a1ac
@ -14,6 +14,12 @@ namespace eShopOnContainers.UnitTests
|
|||||||
bool isValid = mockViewModel.Validate();
|
bool isValid = mockViewModel.Validate();
|
||||||
|
|
||||||
Assert.False(isValid);
|
Assert.False(isValid);
|
||||||
|
Assert.Null(mockViewModel.Forename.Value);
|
||||||
|
Assert.Null(mockViewModel.Surname.Value);
|
||||||
|
Assert.False(mockViewModel.Forename.IsValid);
|
||||||
|
Assert.False(mockViewModel.Surname.IsValid);
|
||||||
|
Assert.NotEmpty(mockViewModel.Forename.Errors);
|
||||||
|
Assert.NotEmpty(mockViewModel.Surname.Errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -26,6 +32,12 @@ namespace eShopOnContainers.UnitTests
|
|||||||
bool isValid = mockViewModel.Validate();
|
bool isValid = mockViewModel.Validate();
|
||||||
|
|
||||||
Assert.False(isValid);
|
Assert.False(isValid);
|
||||||
|
Assert.NotNull(mockViewModel.Forename.Value);
|
||||||
|
Assert.Null(mockViewModel.Surname.Value);
|
||||||
|
Assert.True(mockViewModel.Forename.IsValid);
|
||||||
|
Assert.False(mockViewModel.Surname.IsValid);
|
||||||
|
Assert.Empty(mockViewModel.Forename.Errors);
|
||||||
|
Assert.NotEmpty(mockViewModel.Surname.Errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -38,10 +50,16 @@ namespace eShopOnContainers.UnitTests
|
|||||||
bool isValid = mockViewModel.Validate();
|
bool isValid = mockViewModel.Validate();
|
||||||
|
|
||||||
Assert.False(isValid);
|
Assert.False(isValid);
|
||||||
|
Assert.Null(mockViewModel.Forename.Value);
|
||||||
|
Assert.NotNull(mockViewModel.Surname.Value);
|
||||||
|
Assert.False(mockViewModel.Forename.IsValid);
|
||||||
|
Assert.True(mockViewModel.Surname.IsValid);
|
||||||
|
Assert.NotEmpty(mockViewModel.Forename.Errors);
|
||||||
|
Assert.Empty(mockViewModel.Surname.Errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CheckValidationPassesWhenPropertiesHaveDataTest()
|
public void CheckValidationPassesWhenBothPropertiesHaveDataTest()
|
||||||
{
|
{
|
||||||
ViewModelLocator.RegisterDependencies(true);
|
ViewModelLocator.RegisterDependencies(true);
|
||||||
var mockViewModel = new MockViewModel();
|
var mockViewModel = new MockViewModel();
|
||||||
@ -51,6 +69,12 @@ namespace eShopOnContainers.UnitTests
|
|||||||
bool isValid = mockViewModel.Validate();
|
bool isValid = mockViewModel.Validate();
|
||||||
|
|
||||||
Assert.True(isValid);
|
Assert.True(isValid);
|
||||||
|
Assert.NotNull(mockViewModel.Forename.Value);
|
||||||
|
Assert.NotNull(mockViewModel.Surname.Value);
|
||||||
|
Assert.True(mockViewModel.Forename.IsValid);
|
||||||
|
Assert.True(mockViewModel.Surname.IsValid);
|
||||||
|
Assert.Empty(mockViewModel.Forename.Errors);
|
||||||
|
Assert.Empty(mockViewModel.Surname.Errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user