コード例 #1
0
        public void GivenNoMediaChanges_EmptyCollectionIsReturned()
        {
            var givenMediaInstanceId = "abcdefgh";
            var givenMediaInstance   = new MediaInstance
            {
                Id       = givenMediaInstanceId,
                DataType = "png"
            };

            AddMediaInstance(givenMediaInstance);

            var query = MediaRevisionHistoryQuery.Create(givenMediaInstanceId, string.Empty);
            IRequestHandler <MediaRevisionHistoryQuery, IEnumerable <MediaRevisionHistoryDto> > handler =
                new MediaRevisionHistoryQueryHandler(_contextMock);
            var result = handler.Handle(query, CancellationToken.None).Result;

            result.Should().BeEmpty();
        }
コード例 #2
0
        public void GivenAnotherUsersPrivateMedia_ThenMediaDoesNotBelongToUserIsThrown()
        {
            var givenUser1         = "user1";
            var givenUser2         = "user2";
            var givenMediaId       = "abcdefgh";
            var givenMediaInstance = new MediaInstance()
            {
                Id        = givenMediaId,
                AuthorId  = givenUser1,
                DataType  = "png",
                IsPrivate = true
            };

            AddMediaInstance(givenMediaInstance);

            var query = MediaRevisionHistoryQuery.Create(givenMediaId, givenUser2);
            IRequestHandler <MediaRevisionHistoryQuery, IEnumerable <MediaRevisionHistoryDto> > handler =
                new MediaRevisionHistoryQueryHandler(_contextMock);
            Action act = () => handler.Handle(query, CancellationToken.None).Wait();

            act.Should().Throw <MediaDoesNotBelongToUserException>();
        }
コード例 #3
0
        public void GivenMediaInstanceWithMediaChanges_CorrespondingMediaRevisionHistoryDtoAreReturned()
        {
            var givenUserId            = "user";
            var givenMediaInstanceId   = "abcdefgh";
            var givenMediaCreationTime = new DateTime(2010, 1, 1, 0, 0, 0);
            var givenMediaUpdateTime   = new DateTime(2010, 1, 1, 1, 0, 0);
            var givenMediaChanges      = new List <MediaChange>
            {
                new MediaChange {
                    MediaInstanceId = givenMediaInstanceId, UserId = givenUserId,
                    Timestamp       = givenMediaCreationTime, Type = MediaChangeType.Create
                },
                new MediaChange {
                    MediaInstanceId = givenMediaInstanceId, UserId = givenUserId,
                    Timestamp       = givenMediaUpdateTime, Type = MediaChangeType.Update
                },
            };
            var givenMediaInstance = new MediaInstance
            {
                Id           = givenMediaInstanceId,
                DataType     = "png",
                MediaChanges = givenMediaChanges
            };

            AddMediaInstance(givenMediaInstance);

            var expectedMediaRevisionHistoryDtos = new List <MediaRevisionHistoryDto>
            {
                new MediaRevisionHistoryDto(givenUserId, MediaChangeType.Create, givenMediaCreationTime),
                new MediaRevisionHistoryDto(givenUserId, MediaChangeType.Update, givenMediaUpdateTime)
            };

            var query = MediaRevisionHistoryQuery.Create(givenMediaInstanceId, givenUserId);
            IRequestHandler <MediaRevisionHistoryQuery, IEnumerable <MediaRevisionHistoryDto> > handler =
                new MediaRevisionHistoryQueryHandler(_contextMock);
            var result = handler.Handle(query, CancellationToken.None).Result;

            result.Should().BeEquivalentTo(expectedMediaRevisionHistoryDtos);
        }