public async void TestDelete() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); var createModel = new ApiRetweetRequestModel(); createModel.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("1"), 1); CreateResponse <ApiRetweetResponseModel> createResult = await client.RetweetCreateAsync(createModel); createResult.Success.Should().BeTrue(); ApiRetweetResponseModel getResponse = await client.RetweetGetAsync(2); getResponse.Should().NotBeNull(); ActionResponse deleteResult = await client.RetweetDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiRetweetResponseModel verifyResponse = await client.RetweetGetAsync(2); verifyResponse.Should().BeNull(); }
public async void TestGet() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); ApiRetweetResponseModel response = await client.RetweetGetAsync(1); response.Should().NotBeNull(); }
public async void Get_null_record() { var mock = new ServiceMockFacade <IRetweetRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Retweet>(null)); var service = new RetweetService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.RetweetModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLRetweetMapperMock, mock.DALMapperMockFactory.DALRetweetMapperMock); ApiRetweetResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }