public async Task DeleteAll_Ok() { var testResultEntities = TestEntitiesData.TestResultEntities; var testTableMock = DatabaseTableDeleteTest.GetTestDatabaseTable(testResultEntities); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, testConverter); var resultEntity = await testService.Delete(); Assert.True(resultEntity.OkStatus); }
public async Task Put_Ok() { var testDomainPut = TestData.TestDomains.First(); var testTableMock = DatabaseTablePutMock.GetTestDatabaseTable(); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var validateService = TestValidateServicePutMock.GetDatabaseValidateService(); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, validateService.Object, testConverter); var result = await testService.Put(testDomainPut); Assert.True(result.OkStatus); }
public async Task Post_Collection_OK() { var testDomains = TestData.TestDomains; var testTableMock = DatabaseTablePostMock.GetTestDatabaseTable(); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var validateService = TestValidateServicePostMock.GetDatabaseValidateService(); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, validateService.Object, testConverter); var resultIds = await testService.Post(testDomains); Assert.True(resultIds.OkStatus); Assert.True(resultIds.Value.SequenceEqual(TestData.GetTestIds(testDomains))); }
public async Task Post_Value_SavingError() { var testDomain = TestData.TestDomains.First(); var testTableMock = DatabaseTablePostMock.GetTestDatabaseTable(DatabaseTablePostMock.AddIdError()); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var validateService = TestValidateServicePostMock.GetDatabaseValidateService(); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, validateService.Object, testConverter); var resultId = await testService.Post(testDomain); Assert.True(resultId.HasErrors); Assert.Equal(ErrorResultType.DatabaseTableAccess, resultId.Errors.First().ErrorResultType); }
public async Task Post_Value_OK() { var testDomain = TestData.TestDomains.First(); var testTableMock = DatabaseTablePostMock.GetTestDatabaseTable(); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var validateService = TestValidateServicePostMock.GetDatabaseValidateService(); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, validateService.Object, testConverter); var resultId = await testService.Post(testDomain); Assert.True(resultId.OkStatus); Assert.True(resultId.Value.Equals(testDomain.Id)); }
public async Task Post_Collection_Error() { var testDomains = TestData.TestDomains; var testTableMock = DatabaseTablePostMock.GetTestDatabaseTable(); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var validateService = TestValidateServicePostMock.GetDatabaseValidateService(TestValidateServicePostMock.DuplicateCollectionFunc()); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, validateService.Object, testConverter); var resultIds = await testService.Post(testDomains); Assert.True(resultIds.HasErrors); Assert.Equal(ErrorResultType.DatabaseValueDuplicate, resultIds.Errors.First().ErrorResultType); }
public async Task Put_UpdateError() { var testDomainPut = TestData.TestDomains.First(); var testTableMock = DatabaseTablePutMock.GetTestDatabaseTable(DatabaseTablePutMock.UpdateError()); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var validateService = TestValidateServicePutMock.GetDatabaseValidateService(); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, validateService.Object, testConverter); var result = await testService.Put(testDomainPut); Assert.True(result.HasErrors); Assert.Equal(ErrorResultType.DatabaseTableAccess, result.Errors.First().ErrorResultType); }
public async Task GetId_Error() { var errorInitial = ErrorData.DatabaseError; var testResultEntities = new ResultCollection <TestEntity>(errorInitial); var testTableMock = DatabaseTableGetMock.GetTestDatabaseTable(testResultEntities); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, testConverter); var testResult = await testService.Get(It.IsAny <TestEnum>()); Assert.True(testResult.HasErrors); Assert.Equal(errorInitial.ErrorResultType, testResult.Errors.First().ErrorResultType); }
public async Task GetId_NotFound() { var testResultEntities = TestEntitiesData.TestResultEntities; var testTableMock = DatabaseTableGetMock.GetTestDatabaseTable(testResultEntities, DatabaseTableGetMock.FirstNotFoundFunc(testResultEntities)); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, testConverter); var testResult = await testService.Get(It.IsAny <TestEnum>()); Assert.True(testResult.HasErrors); Assert.Equal(ErrorResultType.ValueNotFound, testResult.Errors.First().ErrorResultType); }
public async Task Delete_DeleteError() { var testDelete = TestData.TestDomains.Last(); var testResultEntities = TestEntitiesData.TestResultEntities; var testTableMock = DatabaseTableDeleteTest.GetTestDatabaseTable(testResultEntities, DatabaseTableDeleteTest.DeleteErrorFunc()); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, testConverter); var resultEntity = await testService.Delete(testDelete.Id); Assert.True(resultEntity.HasErrors); Assert.Equal(ErrorResultType.DatabaseTableAccess, resultEntity.Errors.First().ErrorResultType); }
public async Task DeleteAll_DeleteError() { var errorInitial = ErrorData.DatabaseError; var resultDelete = new ResultError(errorInitial); var testResultEntities = TestEntitiesData.TestResultEntities; var testTableMock = DatabaseTableDeleteTest.GetTestDatabaseTable(testResultEntities, resultDelete); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock.Object); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock.Object, testConverter); var resultEntity = await testService.Delete(); Assert.True(resultEntity.HasErrors); Assert.True(errorInitial.Equals(resultEntity.Errors.First())); }
public async Task Get_OK() { var testEntities = TestEntitiesData.TestEntities; var testTableMock = DatabaseTableGetMock.GetTestDatabaseTable(testEntities); var testDatabaseMock = DatabaseMock.GetTestDatabase(testTableMock); var testConverter = TestEntityConverterMock.TestEntityConverter; var testService = DatabaseServiceMock.GetTestDatabaseService(testDatabaseMock.Object, testTableMock, testConverter); var testResult = await testService.Get(); var testEntitiesGet = testConverter.FromEntities(testEntities); Assert.True(testResult.OkStatus); Assert.True(testResult.Value.SequenceEqual(testEntitiesGet.Value)); }