示例#1
0
        protected override void SetupDatabase(IDocumentStore store)
        {
            store.ExecuteIndex(new FavIndex());

            using var session = store.OpenSession();
            session.Store(FavData.GetFirst());
            session.SaveChanges();

            WaitForIndexing(store);
        }
示例#2
0
        public void FavMasterTest()
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Fav, FavMaster>();
                cfg.CreateMap <FavMaster, Fav>();
            });

            var mapper   = new Mapper(config);
            var master   = mapper.Map <FavMaster>(FavData.GetFirst());
            var document = mapper.Map <Fav>(master);

            master.Should().NotBeNull();
            document.Should().NotBeNull();
        }
示例#3
0
        public async Task FavAddExistingFailDataTest()
        {
            using var store   = GetDocumentStore();
            using var session = store.OpenAsyncSession();

            await session.StoreAsync(FavData.GetFirst());

            await session.SaveChangesAsync();

            WaitForIndexing(store);

            var persist = new FavAdd {
                Session = session, Key = "user", Value = UserData.FirstId, CurrentUser = StandardUser
            };
            await persist.Execute();

            persist.Confirm.Should().NotBeNull();
            persist.Confirm.Success.Should().BeFalse();
            persist.Model.EntityIds.Count.Should().Be(1);
        }
示例#4
0
        public async Task FavControllerRemoveExists()
        {
            var data  = new FavApiDataHandler();
            var model = FavData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <FavRemove>())).Returns(model);
            data.Confirm = ModelConfirm <Fav> .CreateSuccess(model);

            var controller = new FavController(data, Logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Remove("user", UserData.FirstId) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            result.Value.Should().Be(false);

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <FavRemove>()), Times.Once);
        }