コード例 #1
0
        public async Task UsersAddedCanThenBeRemoved()
        {
            var storage = new JsonStorage(new Mock <Serilog.ILogger>().Object);
            var state   = new OptOutState(storage);
            await state.Start();

            storage.DeleteFile("optouts");
            Assert.AreEqual(0, state.ChannelList.Count());

            await state.AddUserToOptOutOfChannel(new Models.Person()
            {
                UserId = "1", UserName = "******"
            }, "testroom");

            await state.AddUserToOptOutOfChannel(new Models.Person()
            {
                UserId = "2", UserName = "******"
            }, "testroom");

            var count = state.ChannelList["testroom"].UsersThatHaveOptedOut.Count();

            Assert.AreEqual(2, count);
            await state.RemoveUserFromOptOutOfChannel(new Models.Person()
            {
                UserId = "2", UserName = "******"
            }, "testroom");

            count = state.ChannelList["testroom"].UsersThatHaveOptedOut.Count();
            Assert.AreEqual(1, count);
        }
コード例 #2
0
        public async Task AddingUsersToOptOutState()
        {
            var count = _state.ChannelList.Count();

            Assert.AreEqual(0, count);

            await _state.AddUserToOptOutOfChannel(new Models.Person()
            {
                UserId = "1", UserName = "******"
            }, "testroom");

            count = _state.ChannelList["testroom"].UsersThatHaveOptedOut.Count();
            Assert.AreEqual(1, count);
        }