Esempio n. 1
0
        public void GivenMediaChangeIsSavedInDatabase_MediaChangeIsOfTypeUpdate()
        {
            var givenUser          = "******";
            var givenMediaId       = "abcdefgh";
            var givenMediaInstance = new MediaInstance
            {
                Id       = givenMediaId,
                AuthorId = givenUser,
                DataType = "png"
            };
            var givenTags = new List <string>
            {
                "test everything"
            };

            _contextMock.MediaInstances.Add(givenMediaInstance);
            _contextMock.SaveChanges();

            var command = UpdateTagsCommand.Create(givenMediaId, givenTags, givenUser);
            var handler = new UpdateTagsCommandHandler(_contextMock, _timeProviderMock.Object);

            handler.Handle(command, CancellationToken.None).Wait();

            _contextMock.MediaChanges.Should().ContainSingle(mc => mc.Type == MediaChangeType.Update);
        }
Esempio n. 2
0
        public void GivenNonexistentFileID_ThenExceptionIsThrown()
        {
            _contextMock.MediaInstances.Add(CreateExampleDatabaseInstance());
            _contextMock.SaveChanges();
            var tags = new List <string>
            {
                "sword", "shield", "minimini"
            };

            var command = UpdateTagsCommand.Create("xdxdxdxd", tags, string.Empty);
            var handler = new UpdateTagsCommandHandler(_contextMock, _timeProviderMock.Object);

            Action act = () => handler.Handle(command, CancellationToken.None).Wait();

            act.Should().Throw <Exception>();
        }
Esempio n. 3
0
        public void GivenMediaTagsAreUpdated_ThenExpectedMediaTagsAreInDatabase()
        {
            _contextMock.MediaInstances.Add(CreateExampleDatabaseInstance());
            _contextMock.SaveChanges();
            var tags = new List <string>
            {
                "sword", "shield", "minimini"
            };

            var command = UpdateTagsCommand.Create("k8wetest", tags, string.Empty);
            var handler = new UpdateTagsCommandHandler(_contextMock, _timeProviderMock.Object);

            handler.Handle(command, CancellationToken.None).Wait();

            _contextMock.MediaInstances.Single().MediaTags.Select(t => t.Tag.Name).Should().BeEquivalentTo(tags);
        }