예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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>()));
        }
예제 #4
0
        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>()));
        }
예제 #5
0
        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>()));
        }
예제 #6
0
        public async void TestGet()
        {
            ApiMachineResponseModel response = await this.Client.MachineGetAsync("A");

            response.Should().NotBeNull();
        }