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); }
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); }