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 ApiMachineRequestModel(); createModel.SetProperties("B", "B", "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B"); CreateResponse <ApiMachineResponseModel> createResult = await client.MachineCreateAsync(createModel); createResult.Success.Should().BeTrue(); ApiMachineResponseModel getResponse = await client.MachineGetAsync(2); getResponse.Should().NotBeNull(); ActionResponse deleteResult = await client.MachineDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiMachineResponseModel verifyResponse = await client.MachineGetAsync(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()); ApiMachineResponseModel response = await client.MachineGetAsync(1); response.Should().NotBeNull(); }
public async void Get_null_record() { var mock = new ServiceMockFacade <IMachineRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <Machine>(null)); var service = new MachineService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.MachineModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLMachineMapperMock, mock.DALMapperMockFactory.DALMachineMapperMock); ApiMachineResponseModel response = await service.Get(default(string)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>())); }
public async void ByMachineGuid_Not_Exists() { var mock = new ServiceMockFacade <IMachineRepository>(); mock.RepositoryMock.Setup(x => x.ByMachineGuid(It.IsAny <Guid>())).Returns(Task.FromResult <Machine>(null)); var service = new MachineService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.MachineModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLMachineMapperMock, mock.DALMapperMockFactory.DALMachineMapperMock, mock.BOLMapperMockFactory.BOLLinkMapperMock, mock.DALMapperMockFactory.DALLinkMapperMock); ApiMachineResponseModel response = await service.ByMachineGuid(default(Guid)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.ByMachineGuid(It.IsAny <Guid>())); }
public async void Get() { var mock = new ServiceMockFacade <IMachineRepository>(); var record = new Machine(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new MachineService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.MachineModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLMachineMapperMock, mock.DALMapperMockFactory.DALMachineMapperMock, mock.BOLMapperMockFactory.BOLLinkMapperMock, mock.DALMapperMockFactory.DALLinkMapperMock, mock.BOLMapperMockFactory.BOLMachineRefTeamMapperMock, mock.DALMapperMockFactory.DALMachineRefTeamMapperMock); ApiMachineResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void TestGet() { ApiMachineResponseModel response = await this.Client.MachineGetAsync("A"); response.Should().NotBeNull(); }