public async Task ValidatePost_Ok() { var test = TestData.TestDomains.First(); var testEntities = Enumerable.Empty <TestEntity>(); var testIncludeValidateService = TestIncludeValidateServiceMock.GetTestIncludeValidateService(); var dbSetTest = TestDatabaseSetMock.GetDbSetTest(testEntities); var testTable = new TestTable(dbSetTest.Object); var testValidateService = new TestDatabaseValidateService(testTable, testIncludeValidateService.Object); var result = await testValidateService.ValidatePost(test); Assert.True(result.OkStatus); }
public async Task ValidatePost_ValidateIncludes() { var test = TestData.TestDomains.First(); var testEntities = Enumerable.Empty <TestEntity>(); var testIncludeValidateService = TestIncludeValidateServiceMock.GetTestIncludeValidateService(TestIncludeValidateServiceMock.ValidateFindsError()); var dbSetTest = TestDatabaseSetMock.GetDbSetTest(testEntities); var testTable = new TestTable(dbSetTest.Object); var testValidateService = new TestDatabaseValidateService(testTable, testIncludeValidateService.Object); var result = await testValidateService.ValidatePost(test); Assert.True(result.HasErrors); Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.ValueNotFound); }
public async Task ValidatePost_ValidateDuplicate() { var test = TestData.TestDomains.First(); var testEntities = TestEntitiesData.TestEntities; var testIncludeValidateService = TestIncludeValidateServiceMock.GetTestIncludeValidateService(); var dbSetTest = TestDatabaseSetMock.GetDbSetTest(testEntities); var testTable = new TestTable(dbSetTest.Object); var testValidateService = new TestDatabaseValidateService(testTable, testIncludeValidateService.Object); var result = await testValidateService.ValidatePost(test); Assert.True(result.HasErrors); Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.DatabaseValueDuplicate); }
public async Task ValidatePost_Collection_ValidateModelError() { var testInvalidName = new TestDomain(TestEnum.First, String.Empty, TestData.TestDomains.First().TestIncludes); var tests = TestData.TestDomains.Append(testInvalidName); var testEntities = Enumerable.Empty <TestEntity>(); var testIncludeValidateService = TestIncludeValidateServiceMock.GetTestIncludeValidateService(); var dbSetTest = TestDatabaseSetMock.GetDbSetTest(testEntities); var testTable = new TestTable(dbSetTest.Object); var testValidateService = new TestDatabaseValidateService(testTable, testIncludeValidateService.Object); var result = await testValidateService.ValidatePost(tests); Assert.True(result.HasErrors); Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.ValueNotValid); }