Example #1
0
        public async Task <ActionResult <RequirementViewModel> > DeleteRequirementAsync(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(BadRequest("No valid id."));
            }

            try
            {
                Requirement oldRequirement = (await requirementService.GetRequirementAsync(id)).Data;
                if (oldRequirement == null)
                {
                    return(NotFound("Requirement not found"));
                }

                TaskResult <Requirement>
                result = await requirementService.RemoveCertificateAsync(oldRequirement);

                if (!result.Succeeded)
                {
                    return(UnprocessableEntity(new ErrorViewModel {
                        Type = Type.Error, Message = result.Message
                    }));
                }
                return(Ok(RequirementViewModel.CreateVm(result.Data)));
            }
            catch (Exception ex)
            {
                string message = GetType().Name + "Error in " + nameof(DeleteRequirementAsync);
                logger.LogError(ex, message);
                return(UnprocessableEntity(new ErrorViewModel {
                    Type = Type.Error, Message = message
                }));
            }
        }
Example #2
0
        public override async Task <CommandBase> GetNewCommand()
        {
            if (await this.Validate())
            {
                IEnumerable <string> commands = this.GetCommandStrings();

                RequirementViewModel requirements = this.Requirements.GetRequirements();

                if (this.command == null || !ChannelSession.Settings.ChatCommands.Contains(this.command))
                {
                    this.command = new ChatCommand(this.NameTextBox.Text, commands, requirements);
                    if (this.autoAddToChatCommands)
                    {
                        ChannelSession.Settings.ChatCommands.Add(this.command);
                    }
                }
                else
                {
                    this.command.Name         = this.NameTextBox.Text;
                    this.command.Commands     = commands.ToList();
                    this.command.Requirements = requirements;
                }

                this.command.IncludeExclamationInCommands = this.IncludeExclamationInCommandsToggleButton.IsChecked.GetValueOrDefault();
                this.command.Unlocked = this.UnlockedControl.Unlocked;

                return(this.command);
            }
            return(null);
        }
Example #3
0
        public async Task <ActionResult <RequirementViewModel> > GetRequirementAsync(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(BadRequest("No valid id."));
            }
            try
            {
                TaskResult <Requirement> result = await requirementService.GetRequirementAsync(id);

                if (!result.Succeeded)
                {
                    if (result.Data == null)
                    {
                        return(NotFound());
                    }
                }
                RequirementViewModel requirementViewModel = RequirementViewModel.CreateVm(result.Data);
                return(Ok(requirementViewModel));
            }
            catch (Exception ex)
            {
                string message = GetType().Name + "Error in " + nameof(GetRequirementAsync);
                logger.LogError(ex, message);
                return(UnprocessableEntity(new ErrorViewModel {
                    Type = Type.Error, Message = message
                }));
            }
        }
Example #4
0
        public ActionResult Details(int?id)
        {
            try
            {
                RequirementViewModel vm = Mapper.Map <RequirementEntity, RequirementViewModel>(requirementService.get(id));

                vm.linkReqArt      = linkReqArtifactService.filter(r => r.RequirementID == id).ToList();
                vm.linkReq         = linkRequirementService.filter(r => r.RequirementOriginID == id || r.RequirementTargetID == id).ToList();
                vm.characteristics = reqCharacteristics.filter(r => r.RequirementID == id).ToList();
                var versionsRequested = versions.filter(r => r.RequirementRequestForChanges != null).ToList();
                var versionsCreated   = versions.filter(r => r.RequirementRequestForChanges == null).ToList();
                vm.versions = versionsRequested.Where(r => r.RequirementRequestForChanges.StakeholderRequirement.RequirementID == id).ToList();
                vm.versions.AddRange(versions.filter(r => r.RequirementID == id));
                vm.stakeholders = stakeholderRequirementService.filter(r => r.RequirementID == id).ToList();

                vm.stakeholdersApproval = stakeholderApproval.filterByRequirement(Convert.ToInt32(id));
                vm.request = requestService.filterByRequirement(Convert.ToInt32(id));

                return(View(vm));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void WindowsNumericVersionSPTypeArchOrGreaterRequirementIsMet()
        {
            RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindowsClientx86Version6.1sp2+");
            bool success = RequirementViewModel.Parse();

            Assert.True(success);
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(2, 0, 0, 0), "Client", "x86"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(3, 1, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(3, 1, 0, 0), "Client", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(2, 1, 0, 0), "Client", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(2, 0, 0, 0), "Server", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(3, 1, 0, 0), "Server", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(3, 1, 0, 0), "Server", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(2, 0, 0, 0), "Server", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(1, 1, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(0, 0, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(1, 1, 0, 0), "Client", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(0, 0, 0, 0), "Client", "x64"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(0, 0, 0, 0), "Client", "x86"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(1, 0, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(0, 0, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(1, 0, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(0, 0, 0, 0), "Server", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(1, 0, 0, 0), "Server", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(0, 0, 0, 0), "Server", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(1, 0, 0, 0), "Server", "x64"));
        }
        public override async Task <CommandBase> GetNewCommand()
        {
            if (await this.Validate())
            {
                InteractiveButtonCommandTriggerType trigger = EnumHelper.GetEnumValueFromString <InteractiveButtonCommandTriggerType>((string)this.ButtonTriggerComboBox.SelectedItem);

                RequirementViewModel requirements = this.Requirements.GetRequirements();

                if (this.command == null)
                {
                    this.command = new InteractiveButtonCommand(this.Game, this.Scene, this.Control, trigger, requirements);
                    ChannelSession.Settings.InteractiveCommands.Add(this.command);
                }

                this.command.Trigger      = trigger;
                this.command.Button.cost  = int.Parse(this.SparkCostTextBox.Text);
                this.command.Unlocked     = this.UnlockedControl.Unlocked;
                this.command.Requirements = requirements;

                await ChannelSession.Connection.UpdateInteractiveGameVersion(this.Version);

                return(this.command);
            }
            return(null);
        }
        public void WindowsNamedVersionSPRequirementIsMet()
        {
            RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindows7sp2");
            bool success = RequirementViewModel.Parse();

            Assert.True(success);
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(2, 0, 0, 0), "Client", "x86"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(3, 1, 0, 0), "Client", "x86"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(3, 1, 0, 0), "Client", "x64"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(2, 1, 0, 0), "Client", "x64"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(2, 0, 0, 0), "Server", "x86"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(3, 1, 0, 0), "Server", "x86"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(3, 1, 0, 0), "Server", "x64"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(2, 0, 0, 0), "Server", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(1, 1, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(0, 0, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(1, 1, 0, 0), "Client", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(0, 0, 0, 0), "Client", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(0, 0, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(1, 0, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(0, 0, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(1, 0, 0, 0), "Client", "x86"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(0, 0, 0, 0), "Server", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(1, 0, 0, 0), "Server", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(0, 0, 0, 0), "Server", "x64"));
            Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(1, 0, 0, 0), "Server", "x64"));
        }
Example #8
0
        public RequirementViewModel GetRequirements()
        {
            RequirementViewModel requirements = this.Requirements.GetRequirements();

            CurrencyModel currency = (CurrencyModel)this.CurrencyTypeComboBox.SelectedItem;
            CurrencyRequirementTypeEnum requirement = this.CurrencyUsage;

            if (requirement == CurrencyRequirementTypeEnum.NoCurrencyCost)
            {
                requirements.Currency = new CurrencyRequirementViewModel(currency, requirement, 0);
            }
            else if (requirement == CurrencyRequirementTypeEnum.RequiredAmount)
            {
                int.TryParse(this.RequiredAmountTextBox.Text, out int required);
                requirements.Currency = new CurrencyRequirementViewModel(currency, requirement, required);
            }
            else if (requirement == CurrencyRequirementTypeEnum.MinimumOnly)
            {
                int.TryParse(this.MinimumAmountTextBox.Text, out int minimum);
                requirements.Currency = new CurrencyRequirementViewModel(currency, requirement, minimum);
            }
            else if (requirement == CurrencyRequirementTypeEnum.MinimumAndMaximum)
            {
                int.TryParse(this.MinimumAmountTextBox.Text, out int minimum);
                int.TryParse(this.MaximumAmountTextBox.Text, out int maximum);
                requirements.Currency = new CurrencyRequirementViewModel(currency, minimum, maximum);
            }

            return(requirements);
        }
Example #9
0
        public async Task <ActionResult <RequirementViewModel> > SaveRequirementAsync(
            RequirementViewModel requirementViewModel)
        {
            if (requirementViewModel == null)
            {
                return(BadRequest("No valid requirement received"));
            }
            if (requirementViewModel.Task == null || requirementViewModel.CertificateType == null)
            {
                return(BadRequest("No valid requirement received"));
            }

            try
            {
                Requirement requirement = (await requirementService.GetRequirementAsync(requirementViewModel.Task.Id,
                                                                                        requirementViewModel.CertificateType.Id)).Data;

                if (requirement != null)
                {
                    return(BadRequest("Requirement already exists."));
                }

                requirement = RequirementViewModel.CreateRequirement(requirementViewModel);
                if (requirement == null)
                {
                    return(BadRequest("Unable to convert RequirementViewModel to Requirement"));
                }

                string oid = IdentityHelper.GetOid(HttpContext.User.Identity as ClaimsIdentity);
                requirement.LastEditBy      = oid;
                requirement.CertificateType = null;
                requirement.Task            = null;
                TaskResult <Requirement> result;
                if (requirementViewModel.Id == Guid.Empty)
                {
                    result = await requirementService.CreateRequirement(requirement);
                }
                else
                {
                    return(BadRequest("Cannot update existing Requirement with post method"));
                }

                if (!result.Succeeded)
                {
                    return(UnprocessableEntity(new ErrorViewModel {
                        Type = Type.Error, Message = result.Message
                    }));
                }
                return(Ok(RequirementViewModel.CreateVm(result.Data)));
            }
            catch (Exception ex)
            {
                string message = GetType().Name + "Error in " + nameof(SaveRequirementAsync);
                logger.LogError(ex, message);
                return(UnprocessableEntity(new ErrorViewModel {
                    Type = Type.Error, Message = message
                }));
            }
        }
Example #10
0
 public OutcomeGameCommandBase(string name, IEnumerable <string> commands, RequirementViewModel requirement, IEnumerable <GameOutcome> outcomes,
                               IEnumerable <GameOutcomeGroup> groups, CustomCommand loseLeftoverCommand)
     : base(name, commands, requirement)
 {
     this.Outcomes            = outcomes.ToList();
     this.Groups              = groups.ToList();
     this.LoseLeftoverCommand = loseLeftoverCommand;
 }
Example #11
0
        public static RequirementViewModel GetRequirementVM()
        {
            if (requirementVM == null)
            {
                requirementVM = new RequirementViewModel();
            }

            return(requirementVM);
        }
        private void AddOutcomeButton_Click(object sender, RoutedEventArgs e)
        {
            RequirementViewModel requirements = this.CommandDetailsControl.GetRequirements();

            if (requirements.Currency != null)
            {
                CurrencyModel currency = requirements.Currency.GetCurrency();
                this.viewModel.AddOutcomeCommand.Execute(currency);
            }
        }
        // GET: Requirement/Edit/5
        public ActionResult Edit(int id)
        {
            string          currentUserId = User.Identity.GetUserId();
            ApplicationUser currentUser   = dbContext.Users.FirstOrDefault(x => x.Id == currentUserId);
            Requirement     req           = currentUser.MyRequirements.FirstOrDefault(x => x.Id == id);

            RequirementViewModel MyRequirement = Mapper.Map <RequirementViewModel>(req);

            return(View(MyRequirement));
        }
Example #14
0
 public void SetRequirements(RequirementViewModel requirement)
 {
     this.RoleRequirement.SetRoleRequirement(requirement.Role);
     this.CooldownRequirement.SetCooldownRequirement(requirement.Cooldown);
     if (this.CurrencyPopup.Visibility == Visibility.Visible)
     {
         this.CurrencyRequirement.SetCurrencyRequirement(requirement.Currency);
     }
     this.RankRequirement.SetCurrencyRequirement(requirement.Rank);
     this.ThresholdRequirement.SetThresholdRequirement(requirement.Threshold);
 }
        public void TestDefinition(string serialized, string expected)
        {
            var builder = new AchievementBuilder();

            builder.ParseRequirements(Tokenizer.CreateTokenizer(serialized));

            var requirement   = builder.ToAchievement().CoreRequirements.First();
            var notes         = new Dictionary <int, string>();
            var vmRequirement = new RequirementViewModel(requirement, NumberFormat.Decimal, notes);

            Assert.That(vmRequirement.Definition, Is.EqualTo(expected));
        }
 public void Windows7NamedVersionOrGreater()
 {
     RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindows7+");
     bool success = RequirementViewModel.Parse();
     Assert.True(success);
     Assert.Equal(RequirementViewModel.Product, "Windows");
     Assert.Equal(RequirementViewModel.NamedVersion, "Windows 7");
     Assert.Equal(RequirementViewModel.Type, null);
     Assert.Equal(RequirementViewModel.Architecture, null);
     Assert.Equal(RequirementViewModel.Version, new Version(6, 1, 0, 0));
     Assert.True(RequirementViewModel.OrGreater);
 }
        public void Windows8NamedVersionOrGreater()
        {
            RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindows8+");
            bool success = RequirementViewModel.Parse();

            Assert.True(success);
            Assert.Equal(RequirementViewModel.Product, "Windows");
            Assert.Equal(RequirementViewModel.NamedVersion, "Windows 8");
            Assert.Equal(RequirementViewModel.Type, null);
            Assert.Equal(RequirementViewModel.Architecture, null);
            Assert.Equal(RequirementViewModel.Version, new Version(6, 2, 0, 0));
            Assert.True(RequirementViewModel.OrGreater);
        }
        public void WindowsServerNumericVersion()
        {
            RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindowsServerVersion6.2");
            bool success = RequirementViewModel.Parse();

            Assert.True(success);
            Assert.Equal(RequirementViewModel.Product, "Windows");
            Assert.Equal(RequirementViewModel.NamedVersion, null);
            Assert.Equal(RequirementViewModel.Type, "Server");
            Assert.Equal(RequirementViewModel.Architecture, null);
            Assert.Equal(RequirementViewModel.Version, new Version(6, 2, 0, 0));
            Assert.False(RequirementViewModel.OrGreater);
        }
Example #19
0
 public void SetRequirements(RequirementViewModel requirement)
 {
     this.RoleRequirement.SetRoleRequirement(requirement.Role);
     this.CooldownRequirement.SetCooldownRequirement(requirement.Cooldown);
     if (this.CurrencyRankInventoryRequirement.CurrencyRequirement.Visibility == Visibility.Visible)
     {
         this.CurrencyRankInventoryRequirement.CurrencyRequirement.SetCurrencyRequirement(requirement.Currency);
     }
     this.CurrencyRankInventoryRequirement.RankRequirement.SetCurrencyRequirement(requirement.Rank);
     this.CurrencyRankInventoryRequirement.InventoryRequirement.SetInventoryRequirement(requirement.Inventory);
     this.ThresholdRequirement.SetThresholdRequirement(requirement.Threshold);
     this.SettingsRequirement.SetSettingsRequirement(requirement.Settings);
 }
Example #20
0
        public RequirementViewModel GetRequirements()
        {
            RequirementViewModel requirement = new RequirementViewModel();

            requirement.Role     = this.RoleRequirement.GetRoleRequirement();
            requirement.Cooldown = this.CooldownRequirement.GetCooldownRequirement();
            if (this.CurrencyPopup.Visibility == Visibility.Visible)
            {
                requirement.Currency = this.CurrencyRequirement.GetCurrencyRequirement();
            }
            requirement.Rank      = this.RankRequirement.GetCurrencyRequirement();
            requirement.Threshold = this.ThresholdRequirement.GetThresholdRequirement();
            return(requirement);
        }
        public void WindowsServer64NumericVersionWithServicePackOrGreater()
        {
            RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindowsServerx64Version6.1sp3.1+");
            bool success = RequirementViewModel.Parse();

            Assert.True(success);
            Assert.Equal(RequirementViewModel.Product, "Windows");
            Assert.Equal(RequirementViewModel.NamedVersion, null);
            Assert.Equal(RequirementViewModel.Type, "Server");
            Assert.Equal(RequirementViewModel.Architecture, "x64");
            Assert.Equal(RequirementViewModel.Version, new Version(6, 1, 0, 0));
            Assert.Equal(RequirementViewModel.ServicePack, new Version(3, 1, 0, 0));
            Assert.True(RequirementViewModel.OrGreater);
        }
        public void WindowsClient32NumericVersionWithServicePackOrGreater()
        {
            RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindowsClientx86Version6.2sp3+");
            bool success = RequirementViewModel.Parse();

            Assert.True(success);
            Assert.Equal(RequirementViewModel.Product, "Windows");
            Assert.Equal(RequirementViewModel.NamedVersion, null);
            Assert.Equal(RequirementViewModel.Type, "Client");
            Assert.Equal(RequirementViewModel.Architecture, "x86");
            Assert.Equal(RequirementViewModel.Version, new Version(6, 2, 0, 0));
            Assert.Equal(RequirementViewModel.ServicePack, new Version(3, 0, 0, 0));
            Assert.True(RequirementViewModel.OrGreater);
        }
        public ActionResult Create(RequirementViewModel viewModel)
        {
            var model = new Requirement()
            {
                Name = viewModel.Name,
                DealId = viewModel.DealId,
                Priority = (RequirementPriority)Enum.Parse(typeof(RequirementPriority), viewModel.Priority)
            };

            this.requirements.Create(model);
            this.requirements.SaveChanges();

            return this.RedirectToAction("Index", "Home", new { area = "Deals" });
        }
        public void Windows7NamedVersion()
        {
            RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindows7");
            bool success = RequirementViewModel.Parse();

            Assert.True(success);
            Assert.Equal(RequirementViewModel.Product, "Windows");
            Assert.Equal(RequirementViewModel.NamedVersion, "Windows 7");
            Assert.Equal(RequirementViewModel.Type, null);
            Assert.Equal(RequirementViewModel.Architecture, null);
            Assert.Equal(RequirementViewModel.Version, new Version(6, 1, 0, 0));
            Assert.False(RequirementViewModel.OrGreater);
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(0, 0, 0, 0), "Client", "x86"));
            Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(0, 0, 0, 0), "Client", "x86"));
        }
Example #25
0
        public static void InitOnce(TestContext context)
        {
            SimpleIoc.Default.Register <IHttpDataServiceFacade>(() =>
            {
                return(new MockedHttpDataServiceFacade());
            });
            SimpleIoc.Default.Register <IDataService <Lookup>, LookupDataService>();
            SimpleIoc.Default.Register <IDataService <Requirement>, RequirementDataService>();

            SimpleIoc.Default.Register <INavigationService>(() =>
            {
                return(new NavigationService());
            });
            SimpleIoc.Default.Register <MvvmDialogs.IDialogService>(() =>
            {
                return(new MvvmDialogs.DialogService());
            });

            var mockConfirmation = new Mock <IActionConfirmationService>();

            mockConfirmation.Setup(c => c.Confirm(ActionConfirmations.Delete))
            .Returns(() => true);
            SimpleIoc.Default.Register(() =>
            {
                return(mockConfirmation.Object);
            });

            SimpleIoc.Default.Register <IBusyStateRegistry>(() =>
            {
                return(new BusyStateRegistry());
            });
            SimpleIoc.Default.Register <MainViewModel>();
            SimpleIoc.Default.Register <RequirementViewModel>();

            User.Current.Initialise("mockToken");

            var serviceLocator = SimpleIoc.Default;
            var mainVM         = serviceLocator.GetInstance <MainViewModel>();

            Assert.IsNotNull(mainVM);
            var busyMngr = mainVM.BusyStateManager;

            Assert.IsNotNull(busyMngr);

            _vm = serviceLocator.GetInstance <RequirementViewModel>();
            Assert.IsNotNull(_vm);
        }
        public void TestNotes(string serialized, string expected)
        {
            var notes = new Dictionary <int, string>();

            notes[0x1234] = "Addr1";
            notes[0x2345] = "Addr2";
            notes[0x3456] = "This note is long enough that it will need to be wrapped.";
            notes[0x4567] = "This note\nis multiple\nlines.";

            var builder = new AchievementBuilder();

            builder.ParseRequirements(Tokenizer.CreateTokenizer(serialized));
            var requirement   = builder.ToAchievement().CoreRequirements.First();
            var vmRequirement = new RequirementViewModel(requirement, NumberFormat.Decimal, notes);

            Assert.That(vmRequirement.Notes, Is.EqualTo(expected));
        }
Example #27
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            await this.window.RunAsyncOperation(async() =>
            {
                int sparkCost = 0;
                if (!int.TryParse(this.SparkCostTextBox.Text, out sparkCost) || sparkCost < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("Spark cost must be 0 or greater");
                    return;
                }

                ActionBase action = this.actionControl.GetAction();
                if (action == null)
                {
                    if (this.actionControl is ChatActionControl)
                    {
                        await MessageBoxHelper.ShowMessageDialog("The chat message must not be empty");
                    }
                    else if (this.actionControl is SoundActionControl)
                    {
                        await MessageBoxHelper.ShowMessageDialog("The sound file path must not be empty");
                    }
                    return;
                }

                RequirementViewModel requirements = new RequirementViewModel();

                if (this.command == null)
                {
                    this.command = new InteractiveTextBoxCommand(this.game, this.scene, this.textBox, requirements);
                    ChannelSession.Settings.InteractiveCommands.Add(this.command);
                }

                this.command.TextBox.cost = sparkCost;
                await ChannelSession.Connection.UpdateInteractiveGameVersion(this.version);

                this.command.UseChatModeration = this.UseChatModerationCheckBox.IsChecked.GetValueOrDefault();
                this.command.IsBasic           = true;
                this.command.Actions.Clear();
                this.command.Actions.Add(action);

                await ChannelSession.SaveSettings();

                this.window.Close();
            });
        }
Example #28
0
        private void AddOutcomeButton_Click(object sender, RoutedEventArgs e)
        {
            UserCurrencyViewModel currency = null;

            RequirementViewModel requirements = this.CommandDetailsControl.GetRequirements();

            if (requirements.Currency != null)
            {
                currency = requirements.Currency.GetCurrency();
            }

            if (currency == null)
            {
                currency = ChannelSession.Settings.Currencies.Values.FirstOrDefault();
            }

            this.outcomes.Add(new SlotMachineOutcome(null, null, null, this.CreateBasicChatCommand("Result: $gameslotsoutcome - @$username walks away with $gamepayout " + currency.Name + "!")));
        }
Example #29
0
        public override async Task <CommandBase> GetNewCommand()
        {
            if (await this.Validate())
            {
                IEnumerable <string> commands = this.GetCommandStrings();

                RequirementViewModel requirements = this.Requirements.GetRequirements();

                if (this.command != null)
                {
                    this.command.Name         = this.NameTextBox.Text;
                    this.command.Commands     = new HashSet <string>(commands);
                    this.command.Requirements = requirements;
                }
                else
                {
                    this.command = new ChatCommand(this.NameTextBox.Text, commands, requirements);
                    if (this.AutoAddToChatCommands && !ChannelSession.Settings.ChatCommands.Contains(this.command))
                    {
                        ChannelSession.Settings.ChatCommands.Add(this.command);
                    }
                }

                this.command.IncludeExclamationInCommands = this.IncludeExclamationInCommandsToggleButton.IsChecked.GetValueOrDefault();
                this.command.Wildcards = this.WildcardsToggleButton.IsChecked.GetValueOrDefault();
                this.command.Unlocked  = this.UnlockedControl.Unlocked;

                this.command.GroupName = !string.IsNullOrEmpty(this.CommandGroupComboBox.Text) ? this.CommandGroupComboBox.Text : null;
                if (!string.IsNullOrEmpty(this.CommandGroupComboBox.Text))
                {
                    if (!ChannelSession.Settings.CommandGroups.ContainsKey(this.CommandGroupComboBox.Text))
                    {
                        ChannelSession.Settings.CommandGroups[this.CommandGroupComboBox.Text] = new CommandGroupSettings(this.CommandGroupComboBox.Text);
                    }
                    ChannelSession.Settings.CommandGroups[this.CommandGroupComboBox.Text].Name = this.CommandGroupComboBox.Text;
                }

                return(this.command);
            }
            return(null);
        }
Example #30
0
 public ActionResult Create(RequirementViewModel vm)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             getModelStateValidations();
         }
         RequirementEntity entity = Mapper.Map <RequirementViewModel, RequirementEntity>(vm);
         setIdUser(ref entity);
         setCreationDate(ref entity);
         Service.add(ref entity);
         success("The Requirement " + entity.title + " was made with Success!");
         ModelState.Clear();
         return(RedirectToAction("Create", new { id = entity.ProjectID }));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #31
0
 public ActionResult Delete(int?id)
 {
     try
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         RequirementEntity    entity = requirementService.get(id);
         RequirementViewModel vm     = Mapper.Map <RequirementEntity, RequirementViewModel>(entity);
         if (vm == null)
         {
             return(HttpNotFound());
         }
         return(View(vm));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #32
0
        public override async Task <CommandBase> GetNewCommand()
        {
            if (await this.Validate())
            {
                RequirementViewModel requirements = this.Requirements.GetRequirements();

                if (this.command == null)
                {
                    this.command = new InteractiveTextBoxCommand(this.Game, this.Scene, this.Control, requirements);
                    ChannelSession.Settings.InteractiveCommands.Add(this.command);
                }

                this.command.TextBox.cost      = int.Parse(this.SparkCostTextBox.Text);
                this.command.UseChatModeration = this.UseChatModerationCheckBox.IsChecked.GetValueOrDefault();
                this.command.Unlocked          = this.UnlockedControl.Unlocked;
                this.command.Requirements      = requirements;

                await ChannelSession.Connection.UpdateInteractiveGameVersion(this.Version);

                return(this.command);
            }
            return(null);
        }
 public void WindowsClient32NumericVersionWithServicePackOrGreater()
 {
     RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindowsClientx86Version6.2sp3+");
     bool success = RequirementViewModel.Parse();
     Assert.True(success);
     Assert.Equal(RequirementViewModel.Product, "Windows");
     Assert.Equal(RequirementViewModel.NamedVersion, null);
     Assert.Equal(RequirementViewModel.Type, "Client");
     Assert.Equal(RequirementViewModel.Architecture, "x86");
     Assert.Equal(RequirementViewModel.Version, new Version(6, 2, 0, 0));
     Assert.Equal(RequirementViewModel.ServicePack, new Version(3, 0, 0, 0));
     Assert.True(RequirementViewModel.OrGreater);
 }
 public void WindowsServer64NumericVersionWithServicePackOrGreater()
 {
     RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindowsServerx64Version6.1sp3.1+");
     bool success = RequirementViewModel.Parse();
     Assert.True(success);
     Assert.Equal(RequirementViewModel.Product, "Windows");
     Assert.Equal(RequirementViewModel.NamedVersion, null);
     Assert.Equal(RequirementViewModel.Type, "Server");
     Assert.Equal(RequirementViewModel.Architecture, "x64");
     Assert.Equal(RequirementViewModel.Version, new Version(6, 1, 0, 0));
     Assert.Equal(RequirementViewModel.ServicePack, new Version(3, 1, 0, 0));
     Assert.True(RequirementViewModel.OrGreater);
 }
 public void WindowsNumericVersionWithArchitecture()
 {
     RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindowsx64Version6.2");
     bool success = RequirementViewModel.Parse();
     Assert.True(success);
     Assert.Equal(RequirementViewModel.Product, "Windows");
     Assert.Equal(RequirementViewModel.NamedVersion, null);
     Assert.Equal(RequirementViewModel.Type, null);
     Assert.Equal(RequirementViewModel.Architecture, "x64");
     Assert.Equal(RequirementViewModel.Version, new Version(6, 2, 0, 0));
     Assert.Equal(RequirementViewModel.ServicePack, null);
     Assert.False(RequirementViewModel.OrGreater);
 }
 public void WindowsNamedVersionSPRequirementIsMet()
 {
     RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindows7sp2");
     bool success = RequirementViewModel.Parse();
     Assert.True(success);
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(2, 0, 0, 0), "Client", "x86"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(3, 1, 0, 0), "Client", "x86"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(3, 1, 0, 0), "Client", "x64"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(2, 1, 0, 0), "Client", "x64"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(2, 0, 0, 0), "Server", "x86"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(3, 1, 0, 0), "Server", "x86"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(3, 1, 0, 0), "Server", "x64"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(2, 0, 0, 0), "Server", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(1, 1, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(0, 0, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(1, 1, 0, 0), "Client", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(0, 0, 0, 0), "Client", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(0, 0, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(1, 0, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(0, 0, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(1, 0, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(0, 0, 0, 0), "Server", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(1, 0, 0, 0), "Server", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(0, 0, 0, 0), "Server", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(1, 0, 0, 0), "Server", "x64"));
 }
 public void WindowsNumericVersionSPTypeArchOrGreaterRequirementIsMet()
 {
     RequirementViewModel RequirementViewModel = new RequirementViewModel("RequiresWindowsClientx86Version6.1sp2+");
     bool success = RequirementViewModel.Parse();
     Assert.True(success);
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(2, 0, 0, 0), "Client", "x86"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(3, 1, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(3, 1, 0, 0), "Client", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(2, 1, 0, 0), "Client", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(2, 0, 0, 0), "Server", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(3, 1, 0, 0), "Server", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(3, 1, 0, 0), "Server", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(2, 0, 0, 0), "Server", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(1, 1, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(0, 0, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 0, 0), new Version(1, 1, 0, 0), "Client", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 1, 1, 1), new Version(0, 0, 0, 0), "Client", "x64"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(0, 0, 0, 0), "Client", "x86"));
     Assert.True(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(1, 0, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(0, 0, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(1, 0, 0, 0), "Client", "x86"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(0, 0, 0, 0), "Server", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 2, 0, 0), new Version(1, 0, 0, 0), "Server", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(0, 0, 0, 0), "Server", "x64"));
     Assert.False(RequirementViewModel.IsMet(new Version(6, 0, 0, 0), new Version(1, 0, 0, 0), "Server", "x64"));
 }