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; IQuoteTweetService service = testServer.Host.Services.GetService(typeof(IQuoteTweetService)) as IQuoteTweetService; var model = new ApiQuoteTweetServerRequestModel(); model.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, TimeSpan.Parse("02:00:00")); CreateResponse <ApiQuoteTweetServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.QuoteTweetDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiQuoteTweetServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public void MapServerRequestToResponse() { var mapper = new ApiQuoteTweetServerModelMapper(); var model = new ApiQuoteTweetServerRequestModel(); model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, TimeSpan.Parse("01:00:00")); ApiQuoteTweetServerResponseModel response = mapper.MapServerRequestToResponse(1, model); response.Should().NotBeNull(); response.Content.Should().Be("A"); response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.RetweeterUserId.Should().Be(1); response.SourceTweetId.Should().Be(1); response.Time.Should().Be(TimeSpan.Parse("01:00:00")); }
public async void Get_ShouldReturnNullBecauseRecordNotFound() { var mock = new ServiceMockFacade <IQuoteTweetService, IQuoteTweetRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <QuoteTweet>(null)); var service = new QuoteTweetService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.QuoteTweetModelValidatorMock.Object, mock.DALMapperMockFactory.DALQuoteTweetMapperMock); ApiQuoteTweetServerResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }