Пример #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;

            IVideoService service = testServer.Host.Services.GetService(typeof(IVideoService)) as IVideoService;
            var           model   = new ApiVideoServerRequestModel();

            model.SetProperties("B", "B", "B");
            CreateResponse <ApiVideoServerResponseModel> createdResponse = await service.Create(model);

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

            ActionResponse deleteResult = await client.VideoDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
Пример #2
0
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiVideoServerModelMapper();
            var model  = new ApiVideoServerRequestModel();

            model.SetProperties("A", "A", "A");
            ApiVideoServerResponseModel response = mapper.MapServerRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.Description.Should().Be("A");
            response.Title.Should().Be("A");
            response.Url.Should().Be("A");
        }
Пример #3
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <IVideoService, IVideoRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Video>(null));
            var service = new VideoService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.VideoModelValidatorMock.Object,
                                           mock.DALMapperMockFactory.DALVideoMapperMock);

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

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