Exemple #1
0
        public async Task HandleAsync_Should_Return_CollectionOutputQuery_With_RoomForRentAnnouncementOutputQuery_When_Input_Is_Null()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .SetRoomTypes(new[] { RoomTypeEnumeration.Double })
                                          .Build();
            var roomForRentAnnouncements = new List <RoomForRentAnnouncement> {
                roomForRentAnnouncement
            };
            var roomForRentAnnouncementOutputQueries = roomForRentAnnouncements.Select(x =>
                                                                                       new RoomForRentAnnouncementOutputQuery(x.Id, x.Title, x.SourceUrl, x.CityId, x.Created, x.Description, x.Price, x.RoomTypes, x.CityDistricts)).ToList();
            var collectionOutputQuery =
                new CollectionOutputQuery <RoomForRentAnnouncementOutputQuery>(roomForRentAnnouncementOutputQueries.Count, roomForRentAnnouncementOutputQueries);

            _roomForRentAnnouncementRepositoryMock.Setup(x => x.GetAllAsync()).ReturnsAsync(roomForRentAnnouncements);
            _roomForRentAnnouncementRepositoryMock.Setup(x => x.CountAsync())
            .ReturnsAsync(roomForRentAnnouncements.Count);
            _mapperMock
            .Setup(x => x.Map <List <RoomForRentAnnouncement>, IEnumerable <RoomForRentAnnouncementOutputQuery> >(It.IsAny <List <RoomForRentAnnouncement> >()))
            .Returns(roomForRentAnnouncementOutputQueries);

            var result = await _queryHandler.HandleAsync(null);

            result.Should().BeEquivalentTo(collectionOutputQuery);
        }
Exemple #2
0
        public async Task HandleAsync_Should_Return_RoomForRentAnnouncementOutputQuery()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Double
            })
                                          .Build();
            var getRoomForRentAnnouncementResult = GetResult <RoomForRentAnnouncement> .Ok(roomForRentAnnouncement);

            var roomForRentAnnouncementOutputQuery = new RoomForRentAnnouncementOutputQuery(roomForRentAnnouncement.Id,
                                                                                            roomForRentAnnouncement.Title, roomForRentAnnouncement.SourceUrl, roomForRentAnnouncement.CityId,
                                                                                            roomForRentAnnouncement.Created, roomForRentAnnouncement.Description, roomForRentAnnouncement.Price,
                                                                                            roomForRentAnnouncement.RoomTypes, roomForRentAnnouncement.CityDistricts);

            _roomForRentAnnouncementGetterServiceMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>()))
            .ReturnsAsync(getRoomForRentAnnouncementResult);
            _mapperMock
            .Setup(x => x.Map <RoomForRentAnnouncement, RoomForRentAnnouncementOutputQuery>(It.IsAny <RoomForRentAnnouncement>()))
            .Returns(roomForRentAnnouncementOutputQuery);

            var result = await _queryHandler.HandleAsync(new GetRoomForRentAnnouncementInputQuery(roomForRentAnnouncement.Id));

            result.Should().BeEquivalentTo(roomForRentAnnouncementOutputQuery);
        }
Exemple #3
0
        public void Should_Throw_RoomForRentAnnouncementTitleMaxLengthException_When_Title_Exceeds_Allowed_Max_Length_Value()
        {
            var    title  = CreateString(257);
            Action result = () =>
            {
                var unused = RoomForRentAnnouncement.Builder()
                             .SetId(Guid.NewGuid())
                             .SetTitle(title)
                             .SetSourceUrl("http://source")
                             .SetCityId(Guid.NewGuid())
                             .SetCreated(DateTimeOffset.UtcNow)
                             .SetDescription("Description")
                             .SetPrice(1000)
                             .SetCityDistricts(new List <Guid> {
                    Guid.NewGuid()
                })
                             .SetRoomTypes(new List <RoomTypeEnumeration> {
                    RoomTypeEnumeration.Single
                })
                             .Build();
            };

            result.Should().ThrowExactly <RoomForRentAnnouncementTitleMaxLengthException>()
            .WithMessage("Title argument max length is 256.");
        }
Exemple #4
0
        public async Task GetByIdAsync_Should_Return_GetResult_Ok()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://sourceUrl")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .SetPrice(100)
                                          .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Double
            })
                                          .Build();
            var expectedResult = GetResult <RoomForRentAnnouncement> .Ok(roomForRentAnnouncement);

            _roomForRentAnnouncementRepositoryMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>()))
            .ReturnsAsync(roomForRentAnnouncement);

            var result = await _service.GetByIdAsync(roomForRentAnnouncement.Id);

            result.Should().BeEquivalentTo(expectedResult);
        }
Exemple #5
0
        public void Should_Throw_RoomForRentAnnouncementRoomTypesDuplicateValuesException_When_RoomTypes_Contains_Duplicate()
        {
            var    roomType = RoomTypeEnumeration.Single;
            Action result   = () =>
            {
                var unused = RoomForRentAnnouncement.Builder()
                             .SetId(Guid.NewGuid())
                             .SetTitle("Title")
                             .SetSourceUrl("http://source")
                             .SetCityId(Guid.NewGuid())
                             .SetCreated(DateTimeOffset.UtcNow)
                             .SetDescription("Description")
                             .SetPrice(1000)
                             .SetCityDistricts(new List <Guid> {
                    Guid.NewGuid()
                })
                             .SetRoomTypes(new List <RoomTypeEnumeration> {
                    roomType, roomType
                })
                             .Build();
            };

            result.Should().ThrowExactly <RoomForRentAnnouncementRoomTypesDuplicateValuesException>()
            .WithMessage("RoomTypes argument contains duplicate values.");
        }
Exemple #6
0
        public async Task GetAllAsync_Should_Return_RoomForRentAnnouncements()
        {
            var roomForRentAnnouncementEntities = await _cosmosStore.Query().ToListAsync();

            var roomForRentAnnouncements = roomForRentAnnouncementEntities
                                           .Select(x => RoomForRentAnnouncement.Builder()
                                                   .SetId(x.Id)
                                                   .SetTitle(x.Title)
                                                   .SetSourceUrl(x.SourceUrl)
                                                   .SetCityId(x.CityId)
                                                   .SetCreated(x.Created)
                                                   .SetDescription(x.Description)
                                                   .SetPrice(x.Price)
                                                   .SetCityDistricts(x.CityDistricts)
                                                   .SetRoomTypes(x.RoomTypes.Select(r => r.ConvertToEnumeration()))
                                                   .Build()
                                                   )
                                           .ToList();

            _mapperMock
            .Setup(x => x.Map <List <RoomForRentAnnouncementEntity>, List <RoomForRentAnnouncement> >(It.IsAny <List <RoomForRentAnnouncementEntity> >()))
            .Returns(roomForRentAnnouncements);
            var result = await _repository.GetAllAsync();

            result.Should().BeEquivalentTo(roomForRentAnnouncements);
        }
Exemple #7
0
        public async Task HandleAsync_Should_Delete_RoomForRentAnnouncement()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Double
            })
                                          .Build();
            var getRoomForRentAnnouncementResult = GetResult <RoomForRentAnnouncement> .Ok(roomForRentAnnouncement);

            var deleteRoomForRentAnnouncementCommand = new DeleteRoomForRentAnnouncementCommand(roomForRentAnnouncement.Id);

            _roomForRentAnnouncementGetterServiceMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>()))
            .ReturnsAsync(getRoomForRentAnnouncementResult);
            _roomForRentAnnouncementRepositoryMock.Setup(x => x.DeleteAsync(It.IsAny <RoomForRentAnnouncement>()))
            .Returns(Task.CompletedTask);

            Func <Task> result = async() => await _commandHandler.HandleAsync(deleteRoomForRentAnnouncementCommand);

            await result.Should().NotThrowAsync <Exception>();
        }
Exemple #8
0
        public async Task HandleAsync_Should_Update_RoomForRentAnnouncement()
        {
            var cityDistrictToRemove    = Guid.NewGuid();
            var roomTypeToRemove        = RoomTypeEnumeration.MultiPerson;
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                cityDistrictToRemove
            })
                                          .SetRoomTypes(new List <RoomTypeEnumeration> {
                roomTypeToRemove
            })
                                          .Build();
            var getRoomForRentAnnouncementResult = GetResult <RoomForRentAnnouncement> .Ok(roomForRentAnnouncement);

            var          cityVerificationResult          = VerificationResult.Ok();
            var          cityDistrictsVerificationResult = VerificationResult.Ok();
            const string newTitle          = "NewTitle";
            var          cityDistrictToAdd = Guid.NewGuid();
            var          roomTypeToAdd     = RoomTypeEnumeration.Single;
            var          updateRoomForRentAnnouncementCommand = new UpdateRoomForRentAnnouncementCommand(
                roomForRentAnnouncement.Id, newTitle, roomForRentAnnouncement.SourceUrl,
                roomForRentAnnouncement.CityId, roomForRentAnnouncement.Description, roomForRentAnnouncement.Price,
                new List <RoomTypeEnumeration> {
                roomTypeToAdd
            }, new List <Guid> {
                cityDistrictToAdd
            });

            _roomForRentAnnouncementGetterServiceMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>()))
            .ReturnsAsync(getRoomForRentAnnouncementResult);
            _cityVerificationServiceMock.Setup(x => x.VerifyCityExistsAsync(It.IsAny <Guid>()))
            .ReturnsAsync(cityVerificationResult);
            _cityDistrictVerificationServiceMock
            .Setup(x => x.VerifyCityDistrictsExistAsync(It.IsAny <Guid>(), It.IsAny <IEnumerable <Guid> >()))
            .ReturnsAsync(cityDistrictsVerificationResult);
            _roomForRentAnnouncementRepositoryMock.Setup(x => x.UpdateAsync(It.IsAny <RoomForRentAnnouncement>()))
            .Returns(Task.CompletedTask);

            Func <Task> result = async() => await _commandHandler.HandleAsync(updateRoomForRentAnnouncementCommand);

            await result.Should().NotThrowAsync <Exception>();

            roomForRentAnnouncement.Title.Should().Be(newTitle);
            roomForRentAnnouncement.CityDistricts.Should().NotContain(cityDistrictToRemove);
            roomForRentAnnouncement.CityDistricts.Should().Contain(cityDistrictToAdd);
            roomForRentAnnouncement.RoomTypes.Should().NotContain(roomTypeToRemove);
            roomForRentAnnouncement.RoomTypes.Should().Contain(roomTypeToAdd);
        }
Exemple #9
0
        public async Task HandleAsync_Should_Create_RoomForRentAnnouncement()
        {
            var cityVerificationResult          = VerificationResult.Ok();
            var cityDistrictsVerificationResult = VerificationResult.Ok();
            var roomForRentAnnouncement         = RoomForRentAnnouncement.Builder()
                                                  .SetId(Guid.NewGuid())
                                                  .SetTitle("Title")
                                                  .SetSourceUrl("http://source")
                                                  .SetCityId(Guid.NewGuid())
                                                  .SetCreated(DateTimeOffset.UtcNow)
                                                  .SetDescription("Description")
                                                  .SetPrice(1000)
                                                  .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                                  .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Single
            })
                                                  .Build();
            var createRoomForRentAnnouncementCommand = new CreateRoomForRentAnnouncementCommand(
                roomForRentAnnouncement.Id,
                roomForRentAnnouncement.Title,
                roomForRentAnnouncement.SourceUrl,
                roomForRentAnnouncement.CityId,
                roomForRentAnnouncement.Description,
                roomForRentAnnouncement.Price,
                roomForRentAnnouncement.RoomTypes,
                roomForRentAnnouncement.CityDistricts);

            _cityVerificationServiceMock.Setup(x => x.VerifyCityExistsAsync(It.IsAny <Guid>()))
            .ReturnsAsync(cityVerificationResult);
            _cityDistrictVerificationServiceMock
            .Setup(x => x.VerifyCityDistrictsExistAsync(It.IsAny <Guid>(), It.IsAny <IEnumerable <Guid> >()))
            .ReturnsAsync(cityDistrictsVerificationResult);
            _mapperMock
            .Setup(x => x.Map <CreateRoomForRentAnnouncementCommand, RoomForRentAnnouncement>(It.IsAny <CreateRoomForRentAnnouncementCommand>()))
            .Returns(roomForRentAnnouncement);
            _roomForRentAnnouncementRepositoryMock
            .Setup(x => x.AddAsync(It.IsAny <RoomForRentAnnouncement>()))
            .Returns(Task.CompletedTask);

            Func <Task> result = async() => await _commandHandler.HandleAsync(createRoomForRentAnnouncementCommand);

            await result.Should().NotThrowAsync <Exception>();
        }
Exemple #10
0
        public RoomForRentAnnouncementProfile()
        {
            CreateMap <RoomForRentAnnouncement, RoomForRentAnnouncementOutputQuery>();

            CreateMap <CreateRoomForRentAnnouncementCommand, RoomForRentAnnouncement>()
            .ForMember(x => x.CityDistricts, opt => opt.Ignore())
            .ForMember(x => x.RoomTypes, opt => opt.Ignore())
            .ConstructUsing(x => RoomForRentAnnouncement.Builder()
                            .SetId(x.RoomForRentAnnouncementId)
                            .SetTitle(x.Title)
                            .SetSourceUrl(x.SourceUrl)
                            .SetCityId(x.CityId)
                            .SetCreated(DateTimeOffset.UtcNow)
                            .SetDescription(x.Description)
                            .SetPrice(x.Price)
                            .SetCityDistricts(x.CityDistricts)
                            .SetRoomTypes(x.RoomTypes)
                            .Build());
        }
Exemple #11
0
        public async Task HandleAsync_Should_Throw_ValidationException_When_Any_Of_CityDistricts_Is_Not_Found()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .Build();
            var getRoomForRentAnnouncementResult = GetResult <RoomForRentAnnouncement> .Ok(roomForRentAnnouncement);

            var cityVerificationResult = VerificationResult.Ok();
            var errors = new Collection <IError>
            {
                new Error(CityDistrictErrorCodeEnumeration.NotFound, CityDistrictErrorMessage.NotFound)
            };
            var cityDistrictsVerificationResult      = VerificationResult.Fail(errors);
            var updateRoomForRentAnnouncementCommand = new UpdateRoomForRentAnnouncementCommand(
                roomForRentAnnouncement.Id, roomForRentAnnouncement.Title, roomForRentAnnouncement.SourceUrl,
                roomForRentAnnouncement.CityId, roomForRentAnnouncement.Description, roomForRentAnnouncement.Price,
                roomForRentAnnouncement.RoomTypes, roomForRentAnnouncement.CityDistricts);

            _roomForRentAnnouncementGetterServiceMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>()))
            .ReturnsAsync(getRoomForRentAnnouncementResult);
            _cityVerificationServiceMock.Setup(x => x.VerifyCityExistsAsync(It.IsAny <Guid>()))
            .ReturnsAsync(cityVerificationResult);
            _cityDistrictVerificationServiceMock
            .Setup(x => x.VerifyCityDistrictsExistAsync(It.IsAny <Guid>(), It.IsAny <IEnumerable <Guid> >()))
            .ReturnsAsync(cityDistrictsVerificationResult);

            Func <Task> result = async() => await _commandHandler.HandleAsync(updateRoomForRentAnnouncementCommand);

            var exceptionResult = await result.Should().ThrowExactlyAsync <ValidationException>();

            exceptionResult.And.Errors.Should().BeEquivalentTo(errors);
        }
Exemple #12
0
        public void Should_Create_RoomForRentAnnouncement()
        {
            var result = RoomForRentAnnouncement.Builder()
                         .SetId(Guid.NewGuid())
                         .SetTitle("Title")
                         .SetSourceUrl("http://source")
                         .SetCityId(Guid.NewGuid())
                         .SetCreated(DateTimeOffset.UtcNow)
                         .SetDescription("Description")
                         .SetPrice(1000)
                         .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                         .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Single
            })
                         .Build();


            result.Should().NotBeNull();
        }
Exemple #13
0
        public void Should_Throw_RoomForRentAnnouncementRoomTypesNullException_When_RoomTypes_Is_Null()
        {
            Action result = () =>
            {
                var unused = RoomForRentAnnouncement.Builder()
                             .SetId(Guid.NewGuid())
                             .SetTitle("Title")
                             .SetSourceUrl("http://source")
                             .SetCityId(Guid.NewGuid())
                             .SetCreated(DateTimeOffset.UtcNow)
                             .SetDescription("Description")
                             .SetPrice(1000)
                             .SetCityDistricts(new List <Guid> {
                    Guid.NewGuid()
                })
                             .SetRoomTypes(null)
                             .Build();
            };

            result.Should().ThrowExactly <RoomForRentAnnouncementRoomTypesNullException>()
            .WithMessage("RoomTypes argument is required.");
        }
Exemple #14
0
        public RoomForRentAnnouncementProfile()
        {
            CreateMap <RoomForRentAnnouncementEntity, RoomForRentAnnouncement>()
            .ForMember(x => x.CityDistricts, opt => opt.Ignore())
            .ForMember(x => x.RoomTypes, opt => opt.Ignore())
            .ConvertUsing(x => RoomForRentAnnouncement.Builder()
                          .SetId(x.Id)
                          .SetTitle(x.Title)
                          .SetSourceUrl(x.SourceUrl)
                          .SetCityId(x.CityId)
                          .SetCreated(x.Created)
                          .SetDescription(x.Description)
                          .SetPrice(x.Price)
                          .SetCityDistricts(x.CityDistricts)
                          .SetRoomTypes(x.RoomTypes.Select(r => r.ConvertToEnumeration()))
                          .Build());

            CreateMap <RoomForRentAnnouncement, RoomForRentAnnouncementEntity>()

            .ForMember(x => x.RoomTypes,
                       opt => opt.MapFrom <RoomTypeEnumerationToRoomTypeEnumValueResolver>());
        }
Exemple #15
0
        public void ChangeCityId_Should_Throw_RoomForRentAnnouncementCityIdInvalidValueException_When_CityId_Is_Empty_Guid()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Single
            })
                                          .Build();

            Action result = () => roomForRentAnnouncement.ChangeCityId(Guid.Empty);

            result.Should().ThrowExactly <RoomForRentAnnouncementCityIdInvalidValueException>()
            .WithMessage("CityId argument is invalid.");
        }
Exemple #16
0
        public void ChangeDescription_Should_Change_Description()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Single
            })
                                          .Build();
            const string newDescription = "New description";

            roomForRentAnnouncement.ChangeDescription(newDescription);

            roomForRentAnnouncement.Description.Should().Be(newDescription);
        }
Exemple #17
0
        public void AddCityDistrict_Should_Add_CityDistrict()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Single
            })
                                          .Build();
            var newCityDistrict = Guid.NewGuid();

            roomForRentAnnouncement.AddCityDistrict(newCityDistrict);

            roomForRentAnnouncement.CityDistricts.Should().Contain(newCityDistrict);
        }
Exemple #18
0
        public void RemoveRoomType_Should_Remove_RoomType()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Single
            })
                                          .Build();
            var roomType = RoomTypeEnumeration.Double;

            roomForRentAnnouncement.RemoveRoomType(roomType);

            roomForRentAnnouncement.RoomTypes.Should().NotContain(roomType);
        }
Exemple #19
0
        public void RemoveRoomType_Should_Throw_RoomForRentAnnouncementRoomTypeNullException_When_RoomType_Is_Null()
        {
            var roomForRentAnnouncement = RoomForRentAnnouncement.Builder()
                                          .SetId(Guid.NewGuid())
                                          .SetTitle("Title")
                                          .SetSourceUrl("http://source")
                                          .SetCityId(Guid.NewGuid())
                                          .SetCreated(DateTimeOffset.UtcNow)
                                          .SetDescription("Description")
                                          .SetPrice(1000)
                                          .SetCityDistricts(new List <Guid> {
                Guid.NewGuid()
            })
                                          .SetRoomTypes(new List <RoomTypeEnumeration> {
                RoomTypeEnumeration.Single
            })
                                          .Build();

            Action result = () => roomForRentAnnouncement.RemoveRoomType(null);

            result.Should().ThrowExactly <RoomForRentAnnouncementRoomTypeNullException>()
            .WithMessage("RoomType argument is required.");
        }
Exemple #20
0
        public void Should_Throw_RoomForRentAnnouncementSourceUrlNullException_When_SourceUrl_Is_Null_Or_Empty(string sourceUrl)
        {
            Action result = () =>
            {
                var unused = RoomForRentAnnouncement.Builder()
                             .SetId(Guid.NewGuid())
                             .SetTitle("Title")
                             .SetSourceUrl(sourceUrl)
                             .SetCityId(Guid.NewGuid())
                             .SetCreated(DateTimeOffset.UtcNow)
                             .SetDescription("Description")
                             .SetPrice(1000)
                             .SetCityDistricts(new List <Guid> {
                    Guid.NewGuid()
                })
                             .SetRoomTypes(new List <RoomTypeEnumeration> {
                    RoomTypeEnumeration.Single
                })
                             .Build();
            };

            result.Should().ThrowExactly <RoomForRentAnnouncementSourceUrlNullException>()
            .WithMessage("SourceUrl argument is required.");
        }
Exemple #21
0
        public void Should_Throw_RoomForRentAnnouncementCityDistrictsInvalidValueException_When_CityDistricts_Contains_New_Guid()
        {
            Action result = () =>
            {
                var unused = RoomForRentAnnouncement.Builder()
                             .SetId(Guid.NewGuid())
                             .SetTitle("Title")
                             .SetSourceUrl("http://source")
                             .SetCityId(Guid.NewGuid())
                             .SetCreated(DateTimeOffset.UtcNow)
                             .SetDescription("Description")
                             .SetPrice(1000)
                             .SetCityDistricts(new List <Guid> {
                    new Guid()
                })
                             .SetRoomTypes(new List <RoomTypeEnumeration> {
                    RoomTypeEnumeration.Single
                })
                             .Build();
            };

            result.Should().ThrowExactly <RoomForRentAnnouncementCityDistrictsInvalidValueException>()
            .WithMessage("CityDistricts argument is invalid.");
        }