Exemplo n.º 1
0
        public void Init()
        {
            currentStateController = App.Current.StateController;
            SetupClass.SetUp();
            limitationPlayers = new CountLicenseLimitation {
                Enabled = true, Maximum = 10, RegisterName = "RAPlayers"
            };
            limitationPlayers2 = new CountLicenseLimitation {
                Enabled = true, Maximum = 20, RegisterName = "RAPlayers"
            };
            limitationTeams = new CountLicenseLimitation {
                Enabled = true, Maximum = 5, RegisterName = "Teams"
            };
            limitationFeature = new FeatureLicenseLimitation {
                Enabled = true, RegisterName = "Feature 1"
            };
            limitationFeature2 = new FeatureLicenseLimitation {
                Enabled = true, RegisterName = "Feature 1"
            };
            limitationFeatureDisabled = new FeatureLicenseLimitation {
                Enabled = false, RegisterName = "Feature 2"
            };

            mockLicenseManager         = new Mock <ILicenseManager> ();
            mockLicenseStatus          = new Mock <ILicenseStatus> ();
            App.Current.LicenseManager = mockLicenseManager.Object;
            mockLicenseManager.SetupGet(obj => obj.LicenseStatus).Returns(mockLicenseStatus.Object);

            mockStateController = new Mock <IStateController> ();
            mockScreenState     = new Mock <IScreenState> ();
            mockStateController.SetupGet(sc => sc.Current).Returns(mockScreenState.Object);
            App.Current.StateController = mockStateController.Object;
        }
        public void OneTimeSetUp()
        {
            SetupClass.SetUp();
            futureProject = Utils.CreateProject();
            futureProject.CreationDate = DateTime.Parse("12/12/9999");
            pastProject = Utils.CreateProject();
            pastProject.CreationDate = DateTime.Parse("12/12/2000");
            nowProject = Utils.CreateProject();
            nowProject.CreationDate = DateTime.Now;

            projectList = new List <LMProject> {
                futureProject,
                pastProject,
                nowProject
            };

            notLimitedLimitation = new CountLicenseLimitation {
                Count   = 0,
                Enabled = false
            };

            limitedLimitation = new CountLicenseLimitation {
                Count   = 0,
                Enabled = true,
                Maximum = 1
            };

            storageMock = new Mock <IStorage> ();
            App.Current.DatabaseManager          = Mock.Of <IStorageManager> ();
            App.Current.DatabaseManager.ActiveDB = storageMock.Object;
        }
Exemplo n.º 3
0
        public void SetLimitationEnabled_ModelSetAfterAndMaxExceeded_AscSortingDoneAndColLimited()
        {
            CountLicenseLimitation ll = new CountLicenseLimitation {
                Enabled = true, Maximum = 2
            };

            col.Model.AddRange(players);
            col.Limitation.Model = ll;

            CheckPlayersInLimitedCollectionBy(new int [] { 0, 2 }, players, col);
        }
Exemplo n.º 4
0
        public void SetLimitationDisabled_ModelSetAfter_NoSortingDone()
        {
            CountLicenseLimitation ll = new CountLicenseLimitation {
                Enabled = false, Maximum = 2
            };

            col.Limitation.Model = ll;
            col.Model.AddRange(players);

            // Assert
            CheckPlayersInLimitedCollectionBy(new int [] { 0, 1, 2 }, players, col);
        }
        public void StateLoad_FeatureLimitation_ConfiguredWithCountLimitation()
        {
            dynamic properties = new ExpandoObject();
            var     limitation = new CountLicenseLimitation();

            limitation.RegisterName = "register_name";
            properties.limitationVM = new CountLimitationVM {
                Model = limitation
            };
            state.LoadState(properties);

            Assert.IsTrue(state.ViewModel.Header == Catalog.GetString("Unlock your team's potential with LongoMatch PRO"));
        }
        public void StateLoad_CountLimitationNoDisplay_ConfiguredWithRegisterName()
        {
            dynamic properties = new ExpandoObject();
            var     limitation = new CountLicenseLimitation();

            limitation.RegisterName = "register_name";
            properties.limitationVM = new CountLimitationVM {
                Model = limitation
            };
            state.LoadState(properties);

            Assert.IsTrue(state.ViewModel.Header.Contains(limitation.RegisterName));
        }
Exemplo n.º 7
0
        public void SetLimitationEnabled_ModelAlreadySetAndMaxExceeded_DescSortingDoneAndColLimited()
        {
            CountLicenseLimitation ll = new CountLicenseLimitation {
                Enabled = true, Maximum = 2
            };

            col.SortByCreationDateDesc = false;

            col.Model.AddRange(players);
            col.Limitation.Model = ll;

            CheckPlayersInLimitedCollectionBy(new int [] { 1, 2 }, players, col);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Add the specified limitation by name.
        /// </summary>
        /// <param name="limitation">Limitation.</param>
        public void Add(CountLicenseLimitation limitation, Command command = null)
        {
            if (Limitations.ContainsKey(limitation.RegisterName))
            {
                throw new InvalidOperationException("Limitations cannot be overwritten");
            }
            CountLimitationVM viewModel = new CountLimitationVM {
                Model = limitation,
            };

            if (command != null)
            {
                viewModel.UpgradeCommand = command;
            }
            Limitations [limitation.RegisterName] = viewModel;
        }
Exemplo n.º 9
0
        public void LimitationService_LicenseChangeEvent_DisablesLimitation()
        {
            //Arrange
            mockLicenseStatus.SetupGet(obj => obj.Limitations).Returns(new List <string> ());

            //Act
            var limitation = new CountLicenseLimitation {
                Enabled      = true,
                Maximum      = 10,
                Count        = 8,
                RegisterName = "TestLimitation"
            };

            service.Add(limitation);
            App.Current.EventsBroker.Publish(new LicenseChangeEvent());

            //Assert
            Assert.IsFalse(limitation.Enabled);
        }
Exemplo n.º 10
0
        public void TestAddWithLimitationEnabledWithSort()
        {
            CountLicenseLimitation ll = new CountLicenseLimitation {
                Enabled = true, Maximum = 3
            };

            col.Limitation.Model = ll;

            col.Model.AddRange(players);
            List <Utils.PlayerDummy> newPlayers = new List <Utils.PlayerDummy> ();

            newPlayers.Add(new Utils.PlayerDummy {
                CreationDate = DateTime.Now.AddMinutes(1), Name = "P4"
            });
            players.AddRange(newPlayers);
            col.Model.AddRange(newPlayers);

            CheckPlayersInLimitedCollectionBy(new int [] { 3, 0, 2 }, players, col);
        }
Exemplo n.º 11
0
        public void TestNotifyCollection()
        {
            // Arrange
            NotifyCollectionChangedEventArgs receivedEvent = null;
            bool limitedEqualsViewModel         = false;
            bool getNotifyEqualsViewModel       = false;
            bool secondViewModelEqualsViewModel = false;

            CountLicenseLimitation ll = new CountLicenseLimitation {
                Enabled = true, Maximum = 3
            };

            col.Limitation.Model = ll;

            col.ViewModels.CollectionChanged        += (sender, e) => receivedEvent = e;
            col.LimitedViewModels.CollectionChanged += (sender, e) =>
                                                       limitedEqualsViewModel = e == receivedEvent &&
                                                                                sender == col.LimitedViewModels;
            col.GetNotifyCollection().CollectionChanged += (sender, e) =>
                                                           getNotifyEqualsViewModel = e == receivedEvent &&
                                                                                      sender == col.LimitedViewModels;
            col.ViewModels.CollectionChanged += (sender, e) =>
                                                secondViewModelEqualsViewModel = e == receivedEvent &&
                                                                                 sender == col.LimitedViewModels;

            //Act
            col.Model.AddRange(players);

            // Assert
            Assert.AreEqual(players.Count, col.LimitedViewModels.Count);
            Assert.IsNotNull(receivedEvent);

            Assert.IsTrue(limitedEqualsViewModel);
            Assert.IsTrue(getNotifyEqualsViewModel);
            Assert.IsTrue(secondViewModelEqualsViewModel);
        }
Exemplo n.º 12
0
        public void TestModifyEnabledLimitationEnableReversedWithoutSort()
        {
            CountLicenseLimitation ll = new CountLicenseLimitation {
                Enabled = true, Maximum = 3
            };

            col.Limitation.Model = ll;

            col.SortByCreationDateDesc = false;
            col.Model.AddRange(players);
            List <Utils.PlayerDummy> newPlayers = new List <Utils.PlayerDummy> ();

            newPlayers.Add(new Utils.PlayerDummy {
                CreationDate = DateTime.Now.AddMinutes(1), Name = "P4"
            });
            players.AddRange(newPlayers);
            col.Model.AddRange(newPlayers);

            CheckPlayersInLimitedCollectionBy(new int [] { 1, 2, 0 }, players, col);

            ll.Enabled = false;

            CheckPlayersInLimitedCollectionBy(new int [] { 1, 2, 0, 3 }, players, col);
        }