示例#1
0
        public void Create_Correct_Venue()
        {
            //Arrange
            var venueDTO = new VenueDTO {
                Name = "one", Description = "o", Address = "ads", Phone = "123"
            };

            //Act
            service.Create(venueDTO);
            var res = service.GetByName("one");

            //Assert
            Assert.AreEqual(res.Name, "one");
        }
示例#2
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IVenueRepository>();
            var model = new ApiVenueRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Venue>())).Returns(Task.FromResult(new Venue()));
            var service = new VenueService(mock.LoggerMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.VenueModelValidatorMock.Object,
                                           mock.BOLMapperMockFactory.BOLVenueMapperMock,
                                           mock.DALMapperMockFactory.DALVenueMapperMock);

            CreateResponse <ApiVenueResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.VenueModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiVenueRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Venue>()));
        }
示例#3
0
        public void Create_Correct_Venue()
        {
            //Arrange
            var venueDTO = new VenueDTO()
            {
                Name = "name", Description = "test", Address = "asd", Phone = "123"
            };

            //Act
            service.Create(venueDTO);
            var res = service.GetByName("name");

            //Assert
            Assert.AreEqual(venueDTO.Name, res.Name);

            service.Delete(res.Id);
        }
        public void ShouldCreateNewVenue()
        {
            // Arrange
            _venueRepository.Setup(repo => repo.Create(It.IsAny <VenueEntity>()));
            // Act
            var venueVm = new Venue
            {
                Name        = "Test 123",
                Description = "Test 321",
                Notes       = "Test 333"
            };

            _venueService.Create(venueVm);
            // Assert
            _venueRepository.Verify(repo =>
                                    repo.Create(
                                        It.Is <VenueEntity>(
                                            e => e.Name == "Test 123" && e.Description == "Test 321" &&
                                            e.Notes == "Test 333"
                                            )), Times.Once());
        }
示例#5
0
        public async void Create_NoErrorsOccurred_ShouldReturnResponse()
        {
            var mock = new ServiceMockFacade <IVenueService, IVenueRepository>();

            var model = new ApiVenueServerRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Venue>())).Returns(Task.FromResult(new Venue()));
            var service = new VenueService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.VenueModelValidatorMock.Object,
                                           mock.DALMapperMockFactory.DALVenueMapperMock);

            CreateResponse <ApiVenueServerResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            response.Success.Should().BeTrue();
            mock.ModelValidatorMockFactory.VenueModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiVenueServerRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Venue>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <VenueCreatedNotification>(), It.IsAny <CancellationToken>()));
        }
示例#6
0
        public async void Create_ErrorsOccurred_ShouldReturnErrorResponse()
        {
            var mock          = new ServiceMockFacade <IVenueService, IVenueRepository>();
            var model         = new ApiVenueServerRequestModel();
            var validatorMock = new Mock <IApiVenueServerRequestModelValidator>();

            validatorMock.Setup(x => x.ValidateCreateAsync(It.IsAny <ApiVenueServerRequestModel>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>()
            {
                new ValidationFailure("text", "test")
            })));
            var service = new VenueService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           validatorMock.Object,
                                           mock.DALMapperMockFactory.DALVenueMapperMock);

            CreateResponse <ApiVenueServerResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            response.Success.Should().BeFalse();
            validatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiVenueServerRequestModel>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <VenueCreatedNotification>(), It.IsAny <CancellationToken>()), Times.Never());
        }