Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
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));
        }
Beispiel #4
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));
        }