Пример #1
0
        public void CreateMediaWithExistingMedaiShouldNotApplyEvent()
        {
            //Arrange
            var title       = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url         = new UrlValue("http://url.com");
            var file        = new MediaFile(Guid.NewGuid(), new UrlValue(
                                                "https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE2ybMU?ver=c5fc&q=90&m=6&h=201&w=358&b=%23FFFFFFFF&l=f&o=t&aim=true"));

            //Act
            var speech = new SpeechAggregate.Speech(title, url, description, SpeechType.Conferences);

            speech.CreateMedia(file, 0);

            Assert.Throws <MediaFileAlreadyExisteDomainException>(() => speech.CreateMedia(file, 0));
            var domainEvent           = speech.GetUncommittedEvents().SingleOrDefault(s => s is MediaFileCreatedEvent);
            var mediaFileCreatedEvent = (MediaFileCreatedEvent)domainEvent;

            //Assert
            Assert.Contains(file, speech.MediaFileItems);

            Assert.NotNull(speech.MediaFileItems.Select(f => f.File));
            Assert.NotNull(domainEvent);
            Assert.True(mediaFileCreatedEvent.AggregateVersion == 1);
            Assert.Equal(Guid.Empty, mediaFileCreatedEvent.AggregateId);
        }
Пример #2
0
        public void CreateMediaWithValidVersionReturnSuccess()
        {
            //Arrange
            var title       = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url         = new UrlValue("http://url.com");
            var file        = new MediaFile(new UrlValue(
                                                "https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE2ybMU?ver=c5fc&q=90&m=6&h=201&w=358&b=%23FFFFFFFF&l=f&o=t&aim=true"));

            //Act
            var speech = new SpeechAggregate.Speech(title, url, description, SpeechType.Conferences);

            speech.CreateMedia(file, 1);
            var domainEvent           = speech.DomainEvents.SingleOrDefault(s => s is MediaFileCreatedEvent);
            var mediaFileCreatedEvent = (MediaFileCreatedEvent)domainEvent;

            //Assert
            Assert.Contains(file, speech.MediaFileItems);

            Assert.NotNull(speech.MediaFileItems.Select(f => f.File));
            Assert.NotNull(domainEvent);
            Assert.True(domainEvent.Version == 2);
            Assert.True(speech.Version == 2);
            Assert.NotNull(mediaFileCreatedEvent);
            Assert.NotNull(mediaFileCreatedEvent.File);
            Assert.NotNull(mediaFileCreatedEvent.File.Value);
        }
        public void EqualityIsFalseWhenObjectsAreDifferentIdentitiesTest()
        {
            //Arrange
            var title = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url = new UrlValue("http://url.com");

            //Act
            var speech1 = new SpeechAggregate.Speech(Guid.NewGuid(), title, url, description, SpeechType.Conferences);
            var speech2 = new SpeechAggregate.Speech(Guid.NewGuid(), title, url, description, SpeechType.Conferences);

            Assert.False(speech1 == speech2);
        }
Пример #4
0
        public void CreateMediaWithNullMediaFile(SpeechType speechType)
        {
            //Arrange
            var title       = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url         = new UrlValue("http://url.com");

            //Act
            var speech = new SpeechAggregate.Speech(title, url, description, speechType);

            //Assert
            Assert.Throws <ArgumentNullAggregateException>(() => speech.CreateMedia(null, 0));
        }
Пример #5
0
        public void CreateMediaWithInvalidVersion()
        {
            //Arrange
            var title       = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url         = new UrlValue("http://url.com");
            var file        = new MediaFile(Guid.NewGuid(), new UrlValue(
                                                "https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE2ybMU?ver=c5fc&q=90&m=6&h=201&w=358&b=%23FFFFFFFF&l=f&o=t&aim=true"));

            //Act
            var speech = new SpeechAggregate.Speech(title, url, description, SpeechType.Conferences);

            Assert.Throws <ConcurrencyException>(() => speech.CreateMedia(file, -1));
        }
Пример #6
0
        public void ApplySpeechDeletedEventWithInvalidAggregateIdShouldRaiseInvalidDomainEventException()
        {
            //Arrange
            var title       = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description(@"Lorem Ipsum is simply dummy text of the printing and typesetting industry.
                                              Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url         = new UrlValue("http://url.com");

            var speech = new SpeechAggregate.Speech(title, url, description, SpeechType.Conferences);

            //Act
            //Assert
            Assert.Throws <InvalidDomainEventException>(() => speech.Apply(new SpeechDeletedEvent(Guid.NewGuid(), It.IsAny <bool>())));
        }
Пример #7
0
        public void ChangeUrlWhenUrlIsNullOrEmptyShouldRaiseArgumentNullAggregateException(string newUrl)
        {
            //Arrange
            var title       = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description(@"Lorem Ipsum is simply dummy text of the printing and typesetting industry.
                                              Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url         = new UrlValue("http://url_new.com");

            var speech = new SpeechAggregate.Speech(title, url, description, SpeechType.Conferences);

            //Act
            //Assert
            Assert.Throws <InvalidLenghtAggregateException>(() => speech.ChangeUrl(new UrlValue(newUrl), It.IsAny <long>()));
        }
Пример #8
0
        public void DeleteSpeechWhenExpectedVersionIsNotEqualsToAggregateVersionShouldRaiseConcurrencyException()
        {
            //Arrange
            long expectedVersion = 1;
            var  title           = new Title("Lorem Ipsum is simply dummy text of the printin");
            var  description     = new Description(@"Lorem Ipsum is simply dummy text of the printing and typesetting industry.
                                              Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var  url             = new UrlValue("http://url.com");

            var speech = new SpeechAggregate.Speech(title, url, description, SpeechType.Conferences);

            //Act
            //Assert
            Assert.Throws <ConcurrencyException>(() => speech.Delete(It.IsAny <Guid>(), expectedVersion));
        }
Пример #9
0
        public void RegisterSpeechWithValidDataReturnsSuccess(SpeechType speechType)
        {
            //Arrange
            var title       = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url         = new UrlValue("http://url.com");

            //Act
            var speech = new SpeechAggregate.Speech(title, url, description, speechType);

            //Assert
            Assert.Equal(title.Value, speech.Title.Value);
            Assert.Equal(description.Value, speech.Description.Value);
            Assert.Equal(url.Value, speech.Url.Value);
            Assert.Equal(speechType.Value, speech.Type.Value);
        }
        public void EqualityIsTrueWhenObjectsAreSameIdentitiesTest()
        {
            //Arrange
            var title = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url = new UrlValue("http://url.com");

            //Act
            var speech1 = new SpeechAggregate.Speech(title, url, description, SpeechType.Conferences);
            var speech2 = new SpeechAggregate.Speech(title, url, description, SpeechType.SelfPacedLabs);

            //Assert
            Assert.Equal(speech1, speech2);
            Assert.True(speech1.Equals(speech2));
            Assert.True(speech1.Equals((object)speech2));
            Assert.Equal(speech1.GetHashCode(), speech2.GetHashCode());
        }
Пример #11
0
        public void DeleteSpeechWhenExpectedVersionIsEqualsToAggregateVersionShouldMarkSpeechAsDeleted()
        {
            //Arrange
            long expectedVersion = 0;
            var  id          = Guid.NewGuid();
            var  title       = new Title("Lorem Ipsum is simply dummy text of the printin");
            var  description = new Description(@"Lorem Ipsum is simply dummy text of the printing and typesetting industry.
                                              Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var  url         = new UrlValue("http://url.com");

            var speech = new SpeechAggregate.Speech(id, title, url, description, SpeechType.Conferences);

            //Act
            speech.Delete(id, expectedVersion);

            //Assert

            Assert.True(speech.IsDeleted);
        }
Пример #12
0
        public void ChangeTitleWithValiidArgumentsShouldApplySpeechTitleChangedEvent()
        {
            //Arrange
            long   expectedVersion = 0;
            string newTitle        = "new Lorem Ipsum is simply dummy text of the printin";
            var    title           = new Title("Lorem Ipsum is simply dummy text of the printin");
            var    description     = new Description(@"Lorem Ipsum is simply dummy text of the printing and typesetting industry.
                                              Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var    url             = new UrlValue("http://url.com");

            var speech = new SpeechAggregate.Speech(title, url, description, SpeechType.Conferences);

            //Act
            speech.ChangeTitle(newTitle, expectedVersion);

            //Assert
            Assert.Equal(newTitle, speech.Title.Value);
            Assert.Equal(description, speech.Description);
            Assert.Equal(url, speech.Url);
        }
Пример #13
0
        public void RegisterSpeechWithValidDataRaiseDomainEvent(SpeechType speechType)
        {
            //Arrange
            var id          = Guid.NewGuid();
            var title       = new Title("Lorem Ipsum is simply dummy text of the printin");
            var description = new Description("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took ");
            var url         = new UrlValue("http://url.com");

            //Act
            var speech            = new SpeechAggregate.Speech(id, title, url, description, speechType);
            var domainEvent       = speech.GetUncommittedEvents().SingleOrDefault();
            var speechCreateEvent = (SpeechCreatedEvent)domainEvent;

            //Assert
            Assert.IsAssignableFrom <SpeechCreatedEvent>(domainEvent);
            Assert.NotNull(speechCreateEvent);
            Assert.Equal(id, speechCreateEvent.AggregateId);
            Assert.Equal(url, speechCreateEvent.Url);
            Assert.Equal(title, speechCreateEvent.Title);
            Assert.Equal(description, speechCreateEvent.Description);
            Assert.Equal(speechType, speechCreateEvent.Type);
            Assert.True(DateTime.UtcNow < speechCreateEvent.OcurrendOn);
        }