Beispiel #1
0
        public async Task UserData_Information_SubscriptionTests()
        {
            //ensure users with no subscriptions don't error out
            var noSubUserName = "******";

            VoatDataInitializer.CreateUser(noSubUserName);

            var userData = new Domain.UserData(noSubUserName);

            //var userData = new Domain.UserData(noSubUserName);
            Assert.AreEqual(0, userData.SubverseSubscriptions.Count());
            Assert.AreEqual(false, userData.HasSubscriptions());
            Assert.AreEqual(false, userData.HasSubscriptions(DomainType.Subverse));

            //test subscription
            var subUserName = "******";

            VoatDataInitializer.CreateUser(subUserName);

            TestHelper.SetPrincipal(subUserName);
            var cmd = new SubscriptionCommand(Domain.Models.DomainType.Subverse, Domain.Models.SubscriptionAction.Subscribe, "unit");
            var x   = await cmd.Execute();

            userData = new Domain.UserData(subUserName);

            Assert.AreEqual(1, userData.SubverseSubscriptions.Count());
            Assert.AreEqual("unit", userData.SubverseSubscriptions.First());
            Assert.AreEqual(true, userData.HasSubscriptions());
            Assert.AreEqual(true, userData.HasSubscriptions(DomainType.Subverse));
            Assert.AreEqual(true, userData.IsUserSubverseSubscriber("unit"));
        }
Beispiel #2
0
        public async Task UserData_Information_SubscriptionTests()
        {
            //ensure users with no subscriptions don't error out
            var noSubUserName = "******";

            TestDataInitializer.CreateUser(noSubUserName);

            var userData = new Domain.UserData(noSubUserName);

            //var userData = new Domain.UserData(noSubUserName);
            Assert.AreEqual(0, userData.SubverseSubscriptions.Count());
            Assert.AreEqual(false, userData.HasSubscriptions());
            Assert.AreEqual(false, userData.HasSubscriptions(DomainType.Subverse));

            //test subscription
            var subUserName = "******";

            TestDataInitializer.CreateUser(subUserName);

            var user = TestHelper.SetPrincipal(subUserName);
            var cmd  = new SubscribeCommand(new DomainReference(DomainType.Subverse, SUBVERSES.Unit), Domain.Models.SubscriptionAction.Subscribe).SetUserContext(user);
            var x    = await cmd.Execute();

            VoatAssert.IsValid(x);

            userData = new Domain.UserData(subUserName);

            Assert.AreEqual(1, userData.SubverseSubscriptions.Count());
            Assert.AreEqual(SUBVERSES.Unit, userData.SubverseSubscriptions.First());
            Assert.AreEqual(true, userData.HasSubscriptions());
            Assert.AreEqual(true, userData.HasSubscriptions(DomainType.Subverse));
            Assert.AreEqual(true, userData.IsUserSubverseSubscriber(SUBVERSES.Unit));
        }