public virtual async void TestDelete() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ITeacherService service = testServer.Host.Services.GetService(typeof(ITeacherService)) as ITeacherService; var model = new ApiTeacherServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), "B", "B", "B", "B", 1); CreateResponse <ApiTeacherServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.TeacherDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiTeacherServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public void MapServerRequestToResponse() { var mapper = new ApiTeacherServerModelMapper(); var model = new ApiTeacherServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A", 1); ApiTeacherServerResponseModel response = mapper.MapServerRequestToResponse(1, model); response.Should().NotBeNull(); response.Birthday.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.Email.Should().Be("A"); response.FirstName.Should().Be("A"); response.LastName.Should().Be("A"); response.Phone.Should().Be("A"); response.UserId.Should().Be(1); }
public async void Get_ShouldReturnNullBecauseRecordNotFound() { var mock = new ServiceMockFacade <ITeacherService, ITeacherRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Teacher>(null)); var service = new TeacherService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.TeacherModelValidatorMock.Object, mock.DALMapperMockFactory.DALTeacherMapperMock, mock.DALMapperMockFactory.DALEventTeacherMapperMock, mock.DALMapperMockFactory.DALRateMapperMock, mock.DALMapperMockFactory.DALTeacherTeacherSkillMapperMock); ApiTeacherServerResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }