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_NotFound() { var testDelete = TestData.TestDomains.Last(); var testResultEntities = TestEntitiesData.TestResultEntities; var testTableMock = DatabaseTableDeleteTest.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 resultEntity = await testService.Delete(testDelete.Id); Assert.True(resultEntity.HasErrors); Assert.Equal(ErrorResultType.ValueNotFound, resultEntity.Errors.First().ErrorResultType); }
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)); }