Esempio n. 1
0
        public void DeleteTagCommandHandler_NotExisting_NoChange()
        {
            //given
            var repository = LiteDbHelper.CreateMemoryDb();
            var handler    = new DeleteTagCommandHandler(repository);
            var command    = new DeleteTagCommand(new Tag());

            //when
            handler.Execute(command);

            //then
            Assert.Empty(repository.Database.Query <Tag>());
        }
Esempio n. 2
0
        public void DeleteTagCommandHandler_MoreObjects_RemovedProperOne()
        {
            //given
            var targetTag  = new Tag();
            var tags       = new[] { targetTag, new Tag(), new Tag(), new Tag() };
            var repository = LiteDbHelper.CreateMemoryDb();
            var handler    = new DeleteTagCommandHandler(repository);
            var command    = new DeleteTagCommand(targetTag);

            repository.Database.UpsertBulk(tags);

            //when
            handler.Execute(command);

            //then
            tags = tags.Skip(1).OrderBy(x => x.Id).ToArray();
            var actualTags = repository.Database.Query <Tag>().OrderBy(x => x.Id).ToArray();

            Assert.Equal(tags.Length, actualTags.Length);
            Assert.Equal(tags, actualTags);
        }