Beispiel #1
0
        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;

            IRateService service = testServer.Host.Services.GetService(typeof(IRateService)) as IRateService;
            var          model   = new ApiRateServerRequestModel();

            model.SetProperties(2m, 1, 1);
            CreateResponse <ApiRateServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.RateDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiRateServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiRateServerModelMapper();
            var model  = new ApiRateServerRequestModel();

            model.SetProperties(1m, 1, 1);
            ApiRateServerResponseModel response = mapper.MapServerRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.AmountPerMinute.Should().Be(1m);
            response.TeacherId.Should().Be(1);
            response.TeacherSkillId.Should().Be(1);
        }
Beispiel #3
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <IRateService, IRateRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Rate>(null));
            var service = new RateService(mock.LoggerMock.Object,
                                          mock.MediatorMock.Object,
                                          mock.RepositoryMock.Object,
                                          mock.ModelValidatorMockFactory.RateModelValidatorMock.Object,
                                          mock.DALMapperMockFactory.DALRateMapperMock);

            ApiRateServerResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }