public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            ChutzpahTracer.TraceInformation("Begin Test Adapter Run Tests");

            var settingsProvider = runContext.RunSettings.GetSettings(AdapterConstants.SettingsName) as ChutzpahAdapterSettingsProvider;
            var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings();

            ChutzpahTracingHelper.Toggle(settings.EnabledTracing);

            var testOptions = new TestOptions
                {
                    TestLaunchMode =
                        runContext.IsBeingDebugged ? TestLaunchMode.Custom:
                        settings.OpenInBrowser ? TestLaunchMode.FullBrowser:
                        TestLaunchMode.HeadlessBrowser,
                    CustomTestLauncher     = runContext.IsBeingDebugged ? new VsDebuggerTestLauncher() : null,
                    MaxDegreeOfParallelism = runContext.IsBeingDebugged ? 1 : settings.MaxDegreeOfParallelism,
                    ChutzpahSettingsFileEnvironments = new ChutzpahSettingsFileEnvironments(settings.ChutzpahSettingsFileEnvironments)
                };

            testOptions.CoverageOptions.Enabled = runContext.IsDataCollectionEnabled;

            var callback = new ParallelRunnerCallbackAdapter(new ExecutionCallback(frameworkHandle, runContext));
            testRunner.RunTests(sources, testOptions, callback);

            ChutzpahTracer.TraceInformation("End Test Adapter Run Tests");

        }
        public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
        {
            ChutzpahTracer.TraceInformation("Begin Test Adapter Discover Tests");

            var settingsProvider = discoveryContext.RunSettings.GetSettings(AdapterConstants.SettingsName) as ChutzpahAdapterSettingsProvider;
            var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings();

            ChutzpahTracingHelper.Toggle(settings.EnabledTracing);

            var testOptions = new TestOptions
            {
                MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism,
                ChutzpahSettingsFileEnvironments = new ChutzpahSettingsFileEnvironments(settings.ChutzpahSettingsFileEnvironments)
            };

            IList<TestError> errors;
            var testCases = testRunner.DiscoverTests(sources, testOptions, out errors);

            ChutzpahTracer.TraceInformation("Sending discovered tests to test case discovery sink");

            foreach (var testCase in testCases)
            {
                var vsTestCase = testCase.ToVsTestCase();
                discoverySink.SendTestCase(vsTestCase);
            }

            foreach (var error in errors)
            {
                logger.SendMessage(TestMessageLevel.Error, RunnerCallback.FormatFileErrorMessage(error));
            }

            ChutzpahTracer.TraceInformation("End Test Adapter Discover Tests");

        }
        public void AllPropertiesCopied()
        {
            var options = new TestOptions();
            var wrappedOptions = new ReadWriteApiPortOptions(options);

            foreach (var property in typeof(IApiPortOptions).GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                Assert.Equal(property.GetValue(options), property.GetValue(wrappedOptions));
            }
        }
示例#4
0
 protected TestOptions WithCoverage(params Action<CoverageOptions>[] mods)
 {
     var opts = new TestOptions
     {
         CoverageOptions = new CoverageOptions
         {
             Enabled = true,
             ExcludePatterns = new[] { "*chai.js*" },
         }
     };
     mods.ToList().ForEach(a => a(opts.CoverageOptions));
     return opts;
 }
示例#5
0
        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            var settingsProvider = runContext.RunSettings.GetSettings(ChutzpahAdapterSettings.SettingsName) as ChutzpahAdapterSettingsService;
            var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings();
            var testOptions = new TestOptions
                {
                    TestFileTimeoutMilliseconds = settings.TimeoutMilliseconds,
                    TestingMode = settings.TestingMode,
                    MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism,
                };

            testOptions.CoverageOptions.Enabled = runContext.IsDataCollectionEnabled;

            var callback = new ParallelRunnerCallbackAdapter(new ExecutionCallback(frameworkHandle, runContext));
            testRunner.RunTests(sources, testOptions, callback);
        }
        public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
        {
            var settingsProvider = discoveryContext.RunSettings.GetSettings(ChutzpahAdapterSettings.SettingsName) as ChutzpahAdapterSettingsService;
            var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings();
            var testOptions = new TestOptions
                {
                    TestFileTimeoutMilliseconds = settings.TimeoutMilliseconds,
                    TestingMode = settings.TestingMode,
                    MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism
                };

            var testCases = testRunner.DiscoverTests(sources, testOptions);
            foreach (var testCase in testCases)
            {
                var vsTestCase = testCase.ToVsTestCase();
                discoverySink.SendTestCase(vsTestCase);
            }
        }
示例#7
0
        public async Task EditAsync_ShouldNotEdit()
        {
            using (var db = new ATMContext(TestOptions.TestDbContextOptions <ATMContext>()))
            {
                // Arrange
                var cardToEdit = SampleData.CARD_NOT_ON_THE_LIST;
                var initCards  = SampleData.CREDITCARDS;
                if (initCards.Exists(cc => cc.Id == cardToEdit.Id || cc.Number == cardToEdit.Number))
                {
                    throw new InvalidOperationException($"Seeding cards already contain the card that is not supposed to be there: {cardToEdit}");
                }
                await db.AddRangeAsync(initCards);

                await db.SaveChangesAsync();

                IRepository <CreditCard> repository = new DbCreditCardRepository(db);

                // Act
                Func <Task> action = async() => await repository.EditAsync(cardToEdit);

                // Assert
                await Assert.ThrowsAsync <ArgumentException>(action);
            }
        }
 public LifeBoardGameMainGameClass(IGamePackageResolver resolver,
                                   IEventAggregator aggregator,
                                   BasicData basic,
                                   TestOptions test,
                                   LifeBoardGameVMData model,
                                   IMultiplayerSaveState state,
                                   IAsyncDelayer delay,
                                   CommandContainer command,
                                   LifeBoardGameGameContainer container,
                                   IBoardProcesses boardProcesses,
                                   ISpinnerProcesses spinnerProcesses,
                                   ITwinProcesses twinProcesses,
                                   IHouseProcesses houseProcesses,
                                   IChooseStockProcesses chooseStockProcesses,
                                   IReturnStockProcesses returnStockProcesses,
                                   ICareerProcesses careerProcesses,
                                   IBasicSalaryProcesses basicSalaryProcesses,
                                   ITradeSalaryProcesses tradeSalaryProcesses,
                                   IStolenTileProcesses stolenTileProcesses,
                                   GameBoardProcesses gameBoard
                                   ) : base(resolver, aggregator, basic, test, model, state, delay, command, container)
 {
     _model                = model;
     _boardProcesses       = boardProcesses; //hopefully i won't regret this.  can always do delegates if necessary as well.
     _spinnerProcesses     = spinnerProcesses;
     _twinProcesses        = twinProcesses;
     _houseProcesses       = houseProcesses;
     _chooseStockProcesses = chooseStockProcesses;
     _returnStockProcesses = returnStockProcesses;
     _careerProcesses      = careerProcesses;
     _basicSalaryProcesses = basicSalaryProcesses;
     _tradeSalaryProcesses = tradeSalaryProcesses;
     _stolenTileProcesses  = stolenTileProcesses;
     _gameBoard            = gameBoard;
     _gameContainer        = container;
 }
示例#9
0
        /// <summary>
        /// Generates a new test environment option specifically for testing the game.
        /// </summary>
        private TestOptions CreateTestOptions(TestOptions customOptions)
        {
            if (customOptions == null)
            {
                customOptions = new TestOptions()
                {
                    Dependency    = base.Dependencies,
                    UseCamera     = true,
                    CleanupMethod = OnTestEnvironmentCleanup,
                };
            }
            else
            {
                // Ensure dependencies include all those used in the game.
                if (customOptions.Dependency == null)
                {
                    customOptions.Dependency = base.Dependencies;
                }
                else
                {
                    customOptions.Dependency.CacheFrom(base.Dependencies, true);
                }

                // Enforce camera use
                customOptions.UseCamera = true;

                // Hook custom cleanup method.
                Action customCleanupMethod = customOptions.CleanupMethod;
                customOptions.CleanupMethod = () =>
                {
                    customCleanupMethod?.Invoke();
                    OnTestEnvironmentCleanup();
                };
            }
            return(customOptions);
        }
示例#10
0
 public Rummy500MainViewModel(CommandContainer commandContainer,
                              Rummy500MainGameClass mainGame,
                              Rummy500VMData viewModel,
                              BasicData basicData,
                              TestOptions test,
                              IGamePackageResolver resolver,
                              Rummy500GameContainer gameContainer
                              )
     : base(commandContainer, mainGame, viewModel, basicData, test, resolver)
 {
     _mainGame      = mainGame;
     _model         = viewModel;
     _gameContainer = gameContainer;
     _model.Deck1.NeverAutoDisable           = true;
     _model.PlayerHand1.AutoSelect           = HandObservable <RegularRummyCard> .EnumAutoType.SelectAsMany;
     _model.MainSets1.SetClickedAsync       += MainSets1_SetClickedAsync;
     _model.DiscardList1.ObjectClickedAsync += DiscardList1_ObjectClickedAsync;
     if (_gameContainer.BasicData !.IsXamarinForms == false)
     {
         _model.DiscardList1.BoardClickedAsync += DiscardList1_BoardClickedAsync; //not for xamarin forms.
     }
     _model.MainSets1.SendEnableProcesses(this, () => _gameContainer !.AlreadyDrew);
     //_model.MainSets1.SendEnableProcesses(this, () => false);
 }
示例#11
0
        public async Task EditAsync_ShouldNotEdit()
        {
            using (var db = new ATMContext(TestOptions.TestDbContextOptions <ATMContext>()))
            {
                // Arrange
                var cardToEdit = ACTION_NOT_IN_SEEDING_ACTIONS;
                var initCards  = ACTION_RESULTS;
                if (initCards.Exists(cc => cc.Id == cardToEdit.Id))
                {
                    throw new InvalidOperationException($"Seeding cards already contain the card that is not supposed to be there: {cardToEdit}");
                }
                await db.AddRangeAsync(initCards);

                await db.SaveChangesAsync();

                IRepository <UserActionResult> repository = new DBUserActionResultRepository(db);

                // Act
                Func <Task> action = async() => await repository.EditAsync(cardToEdit);

                // Assert
                await Assert.ThrowsAsync <ArgumentException>(action);
            }
        }
        public ConnectTheDotsMainView(IEventAggregator aggregator,
                                      TestOptions test, GameBoardGraphicsCP graphicsCP, IGamePackageRegister register
                                      )
        {
            _aggregator = aggregator;
            _aggregator.Subscribe(this);
            register.RegisterControl(_board.Element, "");
            graphicsCP.LinkBoard();
            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(ConnectTheDotsMainViewModel.RestoreScreen));
            }
            _score = new ScoreBoardXF();
            _score.AddColumn("Score", true, nameof(ConnectTheDotsPlayerItem.Score));

            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

            firstInfo.AddRow("Turn", nameof(ConnectTheDotsMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(ConnectTheDotsMainViewModel.Status));


            mainStack.Children.Add(_board);
            mainStack.Children.Add(firstInfo.GetContent);
            mainStack.Children.Add(_score);


            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
示例#13
0
 public PaydayMainGameClass(IGamePackageResolver resolver,
                            IEventAggregator aggregator,
                            BasicData basic,
                            TestOptions test,
                            PaydayVMData model,
                            IMultiplayerSaveState state,
                            IAsyncDelayer delay,
                            CommandContainer command,
                            PaydayGameContainer container,
                            StandardRollProcesses <SimpleDice, PaydayPlayerItem> roller,
                            GameBoardProcesses gameBoard,
                            IMailProcesses mailProcesses,
                            IDealProcesses dealProcesses,
                            ILotteryProcesses lotteryProcesses,
                            IYardSaleProcesses yardSaleProcesses,
                            IBuyProcesses buyProcesses,
                            IChoosePlayerProcesses playerProcesses,
                            IDealBuyChoiceProcesses choiceProcesses,
                            IMoveProcesses moveProcesses
                            ) : base(resolver, aggregator, basic, test, model, state, delay, command, container, roller)
 {
     _model             = model;
     _command           = command;
     _gameBoard         = gameBoard;
     _mailProcesses     = mailProcesses;
     _dealProcesses     = dealProcesses;
     _lotteryProcesses  = lotteryProcesses;
     _yardSaleProcesses = yardSaleProcesses;
     _buyProcesses      = buyProcesses;
     _playerProcesses   = playerProcesses;
     _choiceProcesses   = choiceProcesses;
     _gameContainer     = container;
     _gameContainer.OtherTurnProgressAsync = OtherTurnProgressAsync;
     _gameContainer.SpaceClickedAsync      = _gameBoard.AnimateMoveAsync;
     _gameContainer.ResultsOfMoveAsync     = moveProcesses.ResultsOfMoveAsync;
 }
        public async Task ShouldSendInitialParameters()
        {
            var optionsSent = new TestOptions
            {
                SomeText   = "Text",
                SomeNumber = 42,
            };
            object optionsReceived = null;

            _mockDialog
            .Setup(x => x.BeginDialogAsync(It.IsAny <DialogContext>(), It.IsAny <object>(), It.IsAny <CancellationToken>()))
            .Returns((DialogContext dc, object options, CancellationToken cancellationToken) =>
            {
                optionsReceived = options;
                return(Task.FromResult(new DialogTurnResult(DialogTurnStatus.Complete)));
            });
            var sut = new DialogTestClient(Channels.Test, _mockDialog.Object, optionsSent);

            await sut.SendActivityAsync <IMessageActivity>("test");

            Assert.NotNull(optionsReceived);
            Assert.Equal(optionsSent.SomeText, ((TestOptions)optionsReceived).SomeText);
            Assert.Equal(optionsSent.SomeNumber, ((TestOptions)optionsReceived).SomeNumber);
        }
        public async Task VerifyRefactoringAsync(
            string source,
            string expectedSource,
            IEnumerable <string> additionalFiles = null,
            string equivalenceKey = null,
            TestOptions options   = null,
            CancellationToken cancellationToken = default)
        {
            var code = TestCode.Parse(source);

            var expected = ExpectedTestState.Parse(expectedSource);

            var data = new RefactoringTestData(
                code.Value,
                code.Spans.OrderByDescending(f => f.Start).ToImmutableArray(),
                AdditionalFile.CreateRange(additionalFiles),
                equivalenceKey: equivalenceKey);

            await VerifyRefactoringAsync(
                data,
                expected,
                options,
                cancellationToken : cancellationToken);
        }
示例#16
0
        private readonly Phase10GameContainer _gameContainer; //if not needed, delete.

        public Phase10MainViewModel(CommandContainer commandContainer,
                                    Phase10MainGameClass mainGame,
                                    Phase10VMData viewModel,
                                    BasicData basicData,
                                    TestOptions test,
                                    IGamePackageResolver resolver,
                                    Phase10GameContainer gameContainer
                                    )
            : base(commandContainer, mainGame, viewModel, basicData, test, resolver)
        {
            _mainGame      = mainGame;
            _model         = viewModel;
            _gameContainer = gameContainer;
            _model.Deck1.NeverAutoDisable = true;
            _model.PlayerHand1.AutoSelect = HandObservable <Phase10CardInformation> .EnumAutoType.SelectAsMany;
            var player = _mainGame.PlayerList.GetSelf();

            mainGame.Aggregator.Subscribe(player); //hopefully this works now.
            _model.TempSets.Init(this);
            _model.TempSets.ClearBoard();          //try this too.
            _model.TempSets.SetClickedAsync += TempSets_SetClickedAsync;
            _model.MainSets.SetClickedAsync += MainSets_SetClickedAsync;
            _model.MainSets.SendEnableProcesses(this, () => _gameContainer !.AlreadyDrew);
        }
        public void ConvertTextActivityToOmniFailoverMessage()
        {
            Activity activity = null;

            Assert.Throws <ArgumentNullException>(() => ToWhatsAppInfobipConverter.Convert(activity, TestOptions.Get()));
        }
示例#18
0
 public Options()
 {
     Mirror = new MirrorOptions();
     Play   = new PlayOptions();
     Test   = new TestOptions();
 }
示例#19
0
        public XactikaMainView(IEventAggregator aggregator,
                               TestOptions test,
                               XactikaVMData model,
                               IGamePackageRegister register,
                               StatsBoardCP boardCP
                               )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);
            register.RegisterControl(_stats1.Element, "main");
            boardCP.LinkBoard();
            _score         = new ScoreBoardWPF();
            _playerHandWPF = new BaseHandWPF <XactikaCardInformation, XactikaGraphicsCP, CardGraphicsWPF>();
            _shape1        = new ChooseShapeWPF();
            _trick1        = new SeveralPlayersTrickWPF <EnumShapes, XactikaCardInformation, XactikaGraphicsCP, CardGraphicsWPF, XactikaPlayerItem>();

            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(XactikaMainViewModel.RestoreScreen)
                };
            }


            _score.AddColumn("Cards Left", false, nameof(XactikaPlayerItem.ObjectCount)); //very common.
            _score.AddColumn("Bid Amount", false, nameof(XactikaPlayerItem.BidAmount));
            _score.AddColumn("Tricks Won", false, nameof(XactikaPlayerItem.TricksWon));
            _score.AddColumn("Current Score", false, nameof(XactikaPlayerItem.CurrentScore));
            _score.AddColumn("Total Score", false, nameof(XactikaPlayerItem.TotalScore));
            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(XactikaMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(XactikaMainViewModel.Status));
            firstInfo.AddRow("Round", nameof(XactikaMainViewModel.RoundNumber));
            firstInfo.AddRow("Mode", nameof(XactikaMainViewModel.GameModeText));
            StackPanel shapeStack = new StackPanel();

            shapeStack.Children.Add(_shape1);
            ParentSingleUIContainer parent = new ParentSingleUIContainer()
            {
                Name = nameof(XactikaMainViewModel.ShapeScreen)
            };

            shapeStack.Children.Add(parent);
            Grid tempGrid = new Grid();

            AddAutoRows(tempGrid, 1);
            AddLeftOverColumn(tempGrid, 1);
            AddAutoColumns(tempGrid, 2);
            StackPanel tempStack = new StackPanel();

            tempStack.Orientation = Orientation.Horizontal;
            tempStack.Children.Add(_trick1);
            tempStack.Children.Add(shapeStack);
            AddControlToGrid(tempGrid, tempStack, 0, 0);
            parent = new ParentSingleUIContainer()
            {
                Name = nameof(XactikaMainViewModel.BidScreen)
            };
            AddControlToGrid(tempGrid, parent, 0, 0); // if one is visible, then the other is not
            AddControlToGrid(tempGrid, _stats1, 0, 2);
            AddControlToGrid(tempGrid, _score, 0, 1);
            mainStack.Children.Add(tempGrid);
            mainStack.Children.Add(_playerHandWPF);
            mainStack.Children.Add(firstInfo.GetContent);
            if (restoreP != null)
            {
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
示例#20
0
        public GalaxyCardGameMainView(IEventAggregator aggregator,
                                      TestOptions test,
                                      GalaxyCardGameVMData model,
                                      GalaxyCardGameGameContainer gameContainer
                                      )
        {
            _aggregator    = aggregator;
            _model         = model;
            _model.WinUI   = this;
            _gameContainer = gameContainer;
            _aggregator.Subscribe(this);
            gameContainer.SaveRoot.LoadWin(this);
            _deckGPile     = new BaseDeckWPF <GalaxyCardGameCardInformation, ts, DeckOfCardsWPF <GalaxyCardGameCardInformation> >();
            _score         = new ScoreBoardWPF();
            _playerHandWPF = new BaseHandWPF <GalaxyCardGameCardInformation, ts, DeckOfCardsWPF <GalaxyCardGameCardInformation> >();

            _trick1                  = new TwoPlayerTrickWPF <EnumSuitList, GalaxyCardGameCardInformation, ts, DeckOfCardsWPF <GalaxyCardGameCardInformation> >();
            _trick1.Width            = 500;
            _nextCard                = new DeckOfCardsWPF <GalaxyCardGameCardInformation>();
            _planetStack             = new StackPanel();
            _moonGrid                = new Grid();
            _planetStack.Orientation = Orientation.Horizontal;
            AddLeftOverColumn(_moonGrid, 50);
            AddLeftOverColumn(_moonGrid, 50);
            AddAutoRows(_moonGrid, 1);
            _nextCard.SendSize(ts.TagUsed, _gameContainer.SaveRoot !.WinningCard);
            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(GalaxyCardGameMainViewModel.RestoreScreen)
                };
            }
            var endButton = GetGamingButton("End Turn", nameof(GalaxyCardGameMainViewModel.EndTurnAsync));

            endButton.HorizontalAlignment = HorizontalAlignment.Left;
            endButton.VerticalAlignment   = VerticalAlignment.Top;

            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_trick1);
            otherStack.Children.Add(_nextCard);
            otherStack.Children.Add(_deckGPile);
            mainStack.Children.Add(otherStack);
            _score.AddColumn("Cards Left", false, nameof(GalaxyCardGamePlayerItem.ObjectCount)); //very common.
            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(GalaxyCardGameMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(GalaxyCardGameMainViewModel.Status));

            mainStack.Children.Add(_moonGrid);
            otherStack             = new StackPanel();
            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_playerHandWPF);
            StackPanel finalStack = new StackPanel();

            finalStack.Children.Add(firstInfo.GetContent);
            var button = GetGamingButton("Create New Moon", nameof(GalaxyCardGameMainViewModel.MoonAsync));

            finalStack.Children.Add(endButton);
            finalStack.Children.Add(button);
            otherStack.Children.Add(finalStack);
            mainStack.Children.Add(otherStack);
            otherStack             = new StackPanel();
            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_planetStack);
            otherStack.Children.Add(_score);
            mainStack.Children.Add(otherStack);


            _deckGPile.Margin = new Thickness(5, 5, 5, 5);



            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
 public HomeController(IOptions <TestOptions> options)
 {
     this.options = options.Value;
 }
示例#22
0
 /// <summary>
 /// Provider initialization
 /// </summary>
 public override void Initialize(TestOptions options, MetricReporter reporter)
 {
     base.Initialize(options, reporter);
 }
示例#23
0
 public ToViberActivityConverterTest()
 {
     _adapterOptions      = TestOptions.Get();
     _toActivityConverter = new ToViberActivityConverter(_adapterOptions, NullLogger.Instance);
 }
示例#24
0
		private static int RunTest(TestOptions options)
		{
			var result = 1;
			var solution = LoadSolution(options);

			var tests = new List<Test>();

			foreach (var project in solution.Projects)
			{
				if (project.TestFramework != null)
				{
                    var buildTask = project.ToolChain.Build(console, project, "");

                    buildTask.Wait();

                    if (buildTask.Result)
                    {
                        var awaiter = project.TestFramework.EnumerateTestsAsync(project);
                        awaiter.Wait();

                        foreach (var test in awaiter.Result)
                        {
                            tests.Add(test);
                        }
                    }
                    else
                    {
                        result = 2;
                    }
				}
			}

			foreach (var test in tests)
			{
				test.Run();

				if (test.Pass)
				{
					Console.ForegroundColor = ConsoleColor.Green;
					console.Write("\x1b[32;1m");
				}
				else
				{
					Console.ForegroundColor = ConsoleColor.Red;
					console.Write("\x1b[31;1m");
				}

				console.WriteLine(string.Format("Running Test: [{0}], [{1}]", test.Name, test.Pass ? "Passed" : "Failed"));

				if (!test.Pass)
				{
					console.WriteLine(string.Format("Assertion = [{0}], File=[{1}], Line=[{2}]", test.Assertion, test.File, test.Line));
				}

				Console.ForegroundColor = ConsoleColor.White;
				console.Write("\x1b[39; 49m");

				if (!test.Pass)
				{
					result = 0;
					break;
				}
			}

			return result;
		}
        public async void SendToTheAdminEmail()
        {
            const string adminEmail = "AdminEmail";

            var taskDetailForNotificationModel = new TaskDetailForNotificationModel
            {
                Volunteer = new ApplicationUser { Email = "VolunteerEmail", PhoneNumber = "VolunteerPhoneNumber" },
                CampaignContacts = new List<CampaignContact>
                {
                    new CampaignContact
                    {
                        ContactType = (int) ContactTypes.Primary,
                        Contact = new Contact { Email = adminEmail }
                    }
                }
            };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<TaskDetailForNotificationQuery>()))
                .ReturnsAsync(taskDetailForNotificationModel);

            var options = new TestOptions<GeneralSettings>();
            options.Value.SiteBaseUrl = "localhost";

            var notification = new VolunteerSignedUpNotification
            {
                UserId = Context.Users.First().Id,
                TaskId = Context.Tasks.First().Id
            };

            var target = new NotifyAdminForSignup(Context, mediator.Object, options, null);
            await target.Handle(notification);

            mediator.Verify(x => x.SendAsync(It.Is<NotifyVolunteersCommand>(y => y.ViewModel.EmailRecipients.Contains(adminEmail))), Times.Once);
        }
示例#26
0
        public MilkRunMainView(IEventAggregator aggregator,
                               TestOptions test,
                               MilkRunVMData model,
                               MilkRunGameContainer gameContainer
                               )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);
            _gameContainer = gameContainer;
            _deckGPile     = new BaseDeckXF <MilkRunCardInformation, MilkRunGraphicsCP, CardGraphicsXF>();
            _discardGPile  = new BasePileXF <MilkRunCardInformation, MilkRunGraphicsCP, CardGraphicsXF>();
            _playerHandWPF = new BaseHandXF <MilkRunCardInformation, MilkRunGraphicsCP, CardGraphicsXF>();

            _opponentChocolateDeliveries  = new Label();
            _opponentChocolatePiles       = new BasicMultiplePilesXF <MilkRunCardInformation, MilkRunGraphicsCP, CardGraphicsXF>();
            _opponentStrawberryDeliveries = new Label();
            _opponentStrawberryPiles      = new BasicMultiplePilesXF <MilkRunCardInformation, MilkRunGraphicsCP, CardGraphicsXF>();
            _yourChocolateDeliveries      = new Label();
            _yourChocolatePiles           = new BasicMultiplePilesXF <MilkRunCardInformation, MilkRunGraphicsCP, CardGraphicsXF>();
            _yourStrawberryDeliveries     = new Label();
            _yourStrawberryPiles          = new BasicMultiplePilesXF <MilkRunCardInformation, MilkRunGraphicsCP, CardGraphicsXF>();


            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(MilkRunMainViewModel.RestoreScreen));
            }

            StackLayout otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_deckGPile);
            otherStack.Children.Add(_discardGPile); // can reposition or not even have as well.
            AddPlayArea(otherStack);
            mainStack.Children.Add(otherStack);
            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

            firstInfo.AddRow("Turn", nameof(MilkRunMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(MilkRunMainViewModel.Status));


            StackLayout newStack = new StackLayout();

            mainStack.Children.Add(newStack);
            newStack.HorizontalOptions = LayoutOptions.Center;
            newStack.Margin            = new Thickness(0, 10, 0, 0);
            newStack.Children.Add(_playerHandWPF);
            newStack.Children.Add(firstInfo.GetContent);



            _deckGPile.Margin = new Thickness(5, 5, 5, 5);

            _discardGPile.Margin = new Thickness(5, 5, 5, 5);

            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
示例#27
0
 public ApplicationRoot(IOptions <TestOptions> options, TestService testService)
 {
     this.testService = testService;
     this.options     = options.Value;
 }
示例#28
0
        public LifeCardGameMainView(IEventAggregator aggregator,
                                    TestOptions test,
                                    LifeCardGameVMData model,
                                    LifeCardGameGameContainer gameContainer
                                    )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);
            _gameContainer = gameContainer;
            _deckGPile     = new BaseDeckXF <LifeCardGameCardInformation, LifeCardGameGraphicsCP, CardGraphicsXF>();
            _discardGPile  = new BasePileXF <LifeCardGameCardInformation, LifeCardGameGraphicsCP, CardGraphicsXF>();
            _score         = new ScoreBoardXF();
            _playerHandWPF = new BaseHandXF <LifeCardGameCardInformation, LifeCardGameGraphicsCP, CardGraphicsXF>();
            _currentCard   = new BasePileXF <LifeCardGameCardInformation, LifeCardGameGraphicsCP, CardGraphicsXF>();
            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(LifeCardGameMainViewModel.RestoreScreen));
            }
            _storyStack.Orientation = StackOrientation.Horizontal;
            StackLayout otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_deckGPile);
            otherStack.Children.Add(_discardGPile); // can reposition or not even have as well.
            otherStack.Children.Add(_currentCard);
            mainStack.Children.Add(otherStack);

            otherStack             = new StackLayout();
            otherStack.Orientation = StackOrientation.Horizontal;
            mainStack.Children.Add(otherStack);
            Button button;

            button = GetGamingButton("Years Passed", nameof(LifeCardGameMainViewModel.YearsPassedAsync));
            otherStack.Children.Add(button);
            button = GetGamingButton("Play Card", nameof(LifeCardGameMainViewModel.PlayCardAsync));
            otherStack.Children.Add(button);
            ParentSingleUIContainer parent = new ParentSingleUIContainer(nameof(LifeCardGameMainViewModel.OtherScreen))
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Start
            };

            otherStack.Children.Add(parent);



            _score.AddColumn("Cards Left", true, nameof(LifeCardGamePlayerItem.ObjectCount)); //very common.
            _score.AddColumn("Points", true, nameof(LifeCardGamePlayerItem.Points));
            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

            firstInfo.AddRow("Turn", nameof(LifeCardGameMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(LifeCardGameMainViewModel.Status));
            mainStack.Children.Add(_playerHandWPF);
            otherStack             = new StackLayout();
            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_score);
            otherStack.Children.Add(firstInfo.GetContent);
            mainStack.Children.Add(otherStack);
            StackLayout finalStack = new StackLayout();

            finalStack.Orientation = StackOrientation.Horizontal;
            finalStack.Children.Add(mainStack);
            finalStack.Children.Add(_storyStack);


            _deckGPile.Margin = new Thickness(5, 5, 5, 5);

            _discardGPile.Margin = new Thickness(5, 5, 5, 5);

            if (restoreP != null)
            {
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = finalStack;
        }
        public async void LogTheExceptionIfAnExceptionOccurs()
        {
            var mediator = new Mock<IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny<NotifyVolunteersCommand>()))
                .Throws(new InvalidOperationException("Test Exception"));

            var logger = new Mock<ILogger<NotifyAdminForUserUnenrolls>>();
            var options = new TestOptions<GeneralSettings>();
            options.Value.SiteBaseUrl = "localhost";

            var notification = new VolunteerSignedUpNotification
            {
                UserId = Context.Users.First().Id,
                TaskId = Context.Tasks.First().Id
            };

            var target = new NotifyAdminForSignup(Context, mediator.Object, options, logger.Object);
            await target.Handle(notification);

            logger.Verify(x => x.Log(It.IsAny<LogLevel>(),
                It.IsAny<EventId>(), It.IsAny<object>(),
                It.IsAny<InvalidOperationException>(),
                It.IsAny<Func<object, Exception, string>>()), Times.AtLeastOnce);
        }
 public HeadlessTestRunner(HeadlessRunnerOptions runnerOptions, TestOptions options)
 {
     _runnerOptions = runnerOptions;
     _options       = options;
 }
        public FlinchMainView(IEventAggregator aggregator,
                              TestOptions test,
                              FlinchVMData model
                              )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _deckGPile      = new BaseDeckXF <FlinchCardInformation, FlinchGraphicsCP, CardGraphicsXF>();
            _score          = new ScoreBoardXF();
            _playerHandWPF  = new BaseHandXF <FlinchCardInformation, FlinchGraphicsCP, CardGraphicsXF>();
            _publicGraphics = new PublicPilesXF();
            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(FlinchMainViewModel.RestoreScreen));
            }

            StackLayout otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_deckGPile);
            otherStack.Children.Add(_playerHandWPF);
            _score.AddColumn("In Stock", false, nameof(FlinchPlayerItem.InStock));
            int x;

            for (x = 1; x <= 5; x++) //has to change for flinch.
            {
                var thisStr = "Discard" + x;
                _score.AddColumn(thisStr, false, thisStr);
            }
            _score.AddColumn("Stock Left", false, nameof(FlinchPlayerItem.StockLeft));
            _score.AddColumn("Cards Left", false, nameof(FlinchPlayerItem.ObjectCount)); //very common.
            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

            firstInfo.AddRow("RS Cards", nameof(FlinchMainViewModel.CardsToShuffle));
            firstInfo.AddRow("Turn", nameof(FlinchMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(FlinchMainViewModel.Status));


            Grid tempGrid = new Grid();

            AddLeftOverColumn(tempGrid, 60);
            AddLeftOverColumn(tempGrid, 40);
            mainStack.Children.Add(_publicGraphics);
            mainStack.Children.Add(tempGrid);

            StackLayout tempStack = new StackLayout();

            tempStack.Children.Add(otherStack);
            ParentSingleUIContainer parent = new ParentSingleUIContainer(nameof(FlinchMainViewModel.PlayerPilesScreen));

            tempStack.Children.Add(parent);
            AddControlToGrid(tempGrid, tempStack, 0, 0);


            Button endButton = GetGamingButton("End Turn", nameof(FlinchMainViewModel.EndTurnAsync));

            endButton.HorizontalOptions = LayoutOptions.Start;
            tempStack.Children.Add(endButton);
            tempStack = new StackLayout();
            AddControlToGrid(tempGrid, tempStack, 0, 1);
            tempStack.Children.Add(_score);

            tempStack.Children.Add(firstInfo.GetContent);

            _deckGPile.Margin = new Thickness(5, 5, 5, 5);


            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
示例#32
0
        public BladesOfSteelMainView(IEventAggregator aggregator,
                                     TestOptions test,
                                     BladesOfSteelVMData model,
                                     BladesOfSteelGameContainer gameContainer
                                     )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _deckGPile     = new BaseDeckWPF <RegularSimpleCard, ts, DeckOfCardsWPF <RegularSimpleCard> >();
            _discardGPile  = new BasePileWPF <RegularSimpleCard, ts, DeckOfCardsWPF <RegularSimpleCard> >();
            _score         = new ScoreBoardWPF();
            _playerHandWPF = new BaseHandWPF <RegularSimpleCard, ts, DeckOfCardsWPF <RegularSimpleCard> >();

            _mainDefenseCards = new BaseHandWPF <RegularSimpleCard, ts, DeckOfCardsWPF <RegularSimpleCard> >();
            _opponentDefense  = new BaseHandWPF <RegularSimpleCard, ts, DeckOfCardsWPF <RegularSimpleCard> >();
            _opponentAttack   = new BaseHandWPF <RegularSimpleCard, ts, DeckOfCardsWPF <RegularSimpleCard> >();
            _yourDefense      = new BaseHandWPF <RegularSimpleCard, ts, DeckOfCardsWPF <RegularSimpleCard> >();
            _yourAttack       = new BaseHandWPF <RegularSimpleCard, ts, DeckOfCardsWPF <RegularSimpleCard> >();
            ScoringGuideWPF tempScore = new ScoringGuideWPF();

            _score.AddColumn("Cards Left", true, nameof(BladesOfSteelPlayerItem.ObjectCount), rightMargin: 5);
            _score.AddColumn("Score", true, nameof(BladesOfSteelPlayerItem.Score), rightMargin: 5);



            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(BladesOfSteelMainViewModel.RestoreScreen)
                };
            }


            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;

            otherStack.Children.Add(tempScore);
            otherStack.Children.Add(_score);
            mainStack.Children.Add(otherStack);

            otherStack             = new StackPanel();
            otherStack.Orientation = Orientation.Horizontal;
            mainStack.Children.Add(otherStack);

            StackPanel firstStack = new StackPanel();

            AddVerticalLabelGroup("Instructions", nameof(BladesOfSteelMainViewModel.Instructions), firstStack);
            otherStack.Children.Add(firstStack);
            Grid playerArea = new Grid();

            AddAutoColumns(playerArea, 3);
            AddAutoRows(playerArea, 2);
            _opponentDefense.Margin = new Thickness(0, 0, 0, 20);
            AddControlToGrid(playerArea, _opponentDefense, 0, 2);
            AddControlToGrid(playerArea, _opponentAttack, 0, 1);
            _opponentAttack.Margin = new Thickness(0, 0, 0, 20);
            AddControlToGrid(playerArea, _mainDefenseCards, 1, 0);
            AddControlToGrid(playerArea, _yourAttack, 1, 1);
            AddControlToGrid(playerArea, _yourDefense, 1, 2);
            mainStack.Children.Add(playerArea);
            otherStack             = new StackPanel();
            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_deckGPile);
            otherStack.Children.Add(_discardGPile);
            AddControlToGrid(playerArea, otherStack, 0, 0);
            otherStack             = new StackPanel();
            otherStack.Orientation = Orientation.Horizontal;
            mainStack.Children.Add(otherStack);
            var endButton = GetGamingButton("End Turn", nameof(BladesOfSteelMainViewModel.EndTurnAsync));

            endButton.HorizontalAlignment = HorizontalAlignment.Left;
            endButton.VerticalAlignment   = VerticalAlignment.Center;
            otherStack.Children.Add(endButton);
            var otherBut = GetGamingButton("Pass", nameof(BladesOfSteelMainViewModel.PassAsync));

            otherStack.Children.Add(otherBut);
            otherBut.HorizontalAlignment = HorizontalAlignment.Left;
            otherBut.VerticalAlignment   = VerticalAlignment.Center;
            otherStack.Children.Add(_playerHandWPF);
            _deckGPile.Margin                 = new Thickness(5, 5, 5, 5);
            _discardGPile.Margin              = new Thickness(5, 5, 5, 5);
            _deckGPile.HorizontalAlignment    = HorizontalAlignment.Left;
            _deckGPile.VerticalAlignment      = VerticalAlignment.Top;
            _discardGPile.HorizontalAlignment = HorizontalAlignment.Left;
            _discardGPile.VerticalAlignment   = VerticalAlignment.Top;

            if (restoreP != null)
            {
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            _score !.LoadLists(gameContainer.PlayerList !);
            _playerHandWPF !.LoadList(_model.PlayerHand1 !, ts.TagUsed); // i think
            _discardGPile !.Init(_model.Pile1 !, ts.TagUsed);            // may have to be here (well see)
            _discardGPile.StartListeningDiscardPile();                   // its the main one.

            _deckGPile !.Init(_model.Deck1 !, ts.TagUsed);               // try here.  may have to do something else as well (?)
            _deckGPile.StartListeningMainDeck();


            _mainDefenseCards !.LoadList(_model.MainDefense1 !, ts.TagUsed);
            _yourAttack !.LoadList(_model.YourAttackPile !, ts.TagUsed);
            _yourDefense !.LoadList(_model.YourDefensePile !, ts.TagUsed);
            _opponentAttack !.LoadList(_model.OpponentAttackPile !, ts.TagUsed);
            _opponentDefense !.LoadList(_model.OpponentDefensePile !, ts.TagUsed);

            Content = mainStack;
        }
示例#33
0
        private static int RunTest(TestOptions options)
        {
            var result   = 1;
            var solution = LoadSolution(options);

            var tests = new List <Test>();

            foreach (var project in solution.Projects)
            {
                if (project.TestFramework != null)
                {
                    var buildTask = project.ToolChain.Build(console, project, "");

                    buildTask.Wait();

                    if (buildTask.Result)
                    {
                        var awaiter = project.TestFramework.EnumerateTestsAsync(project);
                        awaiter.Wait();

                        foreach (var test in awaiter.Result)
                        {
                            tests.Add(test);
                        }
                    }
                    else
                    {
                        result = 2;
                    }
                }
            }

            foreach (var test in tests)
            {
                test.Run();

                if (test.Pass)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    console.Write("\x1b[32;1m");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    console.Write("\x1b[31;1m");
                }

                console.WriteLine(string.Format("Running Test: [{0}], [{1}]", test.Name, test.Pass ? "Passed" : "Failed"));

                if (!test.Pass)
                {
                    console.WriteLine(string.Format("Assertion = [{0}], File=[{1}], Line=[{2}]", test.Assertion, test.File, test.Line));
                }

                Console.ForegroundColor = ConsoleColor.White;
                console.Write("\x1b[39; 49m");

                if (!test.Pass)
                {
                    result = 0;
                    break;
                }
            }

            return(result);
        }
示例#34
0
 public void LoadBoard(PlayerCollection <SequenceDicePlayerItem> playerList, TestOptions thisTest, SequenceDiceVMData model)
 {
     //has to be done this way so it can figure out what it needs.
     _model = model;
     if (_didInit == true)
     {
         return;
     }
     if (playerList.Count() == 2)
     {
         _winList = _privateBoard.GetPossibleCombinations(6);
     }
     else if (playerList.Count() == 3)
     {
         _winList = _privateBoard.GetPossibleCombinations(5);
     }
     else
     {
         throw new BasicBlankException("Should have been 2 or 3 players.  Rethink");
     }
     _privateBoard.MainObjectSelector = Items => Items.Player;
     _didInit = true;
     //_thisMod = thisMod;
     _thisTest = thisTest;
     if (_autoResume == true)
     {
         return;
     }
     _privateBoard.ForEach(thisSpace =>
     {
         //populate the numbers.  that is needed for lots of things.
         if (thisSpace.Vector.Row == 1 & thisSpace.Vector.Column == 1 |
             thisSpace.Vector.Row == 6 & thisSpace.Vector.Column == 6 |
             thisSpace.Vector.Row == 1 & thisSpace.Vector.Column == 6 |
             thisSpace.Vector.Row == 6 & thisSpace.Vector.Column == 1)
         {
             thisSpace.Number = 2;
         }
         else if (((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 1)) |
                  ((thisSpace.Vector.Row == 1) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 6)) |
                  ((thisSpace.Vector.Row == 6) & (thisSpace.Vector.Column == 5)))
         {
             thisSpace.Number = 3;
         }
         else if (((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 1)) |
                  ((thisSpace.Vector.Row == 1) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 6)) |
                  ((thisSpace.Vector.Row == 6) & (thisSpace.Vector.Column == 4)))
         {
             thisSpace.Number = 4;
         }
         else if (((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 1)) |
                  ((thisSpace.Vector.Row == 1) & (thisSpace.Vector.Column == 4)) |
                  ((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 6)) |
                  ((thisSpace.Vector.Row == 6) & (thisSpace.Vector.Column == 3)))
         {
             thisSpace.Number = 5;
         }
         else if (((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 1)) |
                  ((thisSpace.Vector.Row == 1) & (thisSpace.Vector.Column == 5)) |
                  ((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 6)) |
                  ((thisSpace.Vector.Row == 6) & (thisSpace.Vector.Column == 2)))
         {
             thisSpace.Number = 6;
         }
         else if (((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 5)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 5)))
         {
             thisSpace.Number = 7;
         }
         else if (((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 4)) |
                  ((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 5)))
         {
             thisSpace.Number = 8;
         }
         else if (((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 4)) |
                  ((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 5)))
         {
             thisSpace.Number = 9;
         }
         else if (((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 4)) |
                  ((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 4)))
         {
             thisSpace.Number = 12;
         }
         else
         {
             throw new BasicBlankException($"Cannnot find a space for {thisSpace.Vector.Row} row, {thisSpace.Vector.Column} column");
         }
     });
 }
        private void RunTests(IEnumerable<string> filePaths, bool openInBrowser = false, bool withCodeCoverage = false, bool withDebugger = false)
        {
            if (!testingInProgress)
            {
                lock (syncLock)
                {
                    if (!testingInProgress)
                    {
                        dte.Documents.SaveAll();
                        var solutionDir = Path.GetDirectoryName(dte.Solution.FullName);
                        testingInProgress = true;

                        Task.Factory.StartNew(
                            () =>
                            {
                                try
                                {
                                    // If settings file environments have not yet been initialized, do so here.
                                    if (settingsEnvironments == null || settingsEnvironments.Count == 0)
                                    {
                                        InitializeSettingsFileEnvironments();
                                    }

                                    var options = new TestOptions
                                                      {
                                                          MaxDegreeOfParallelism = Settings.MaxDegreeOfParallelism,
                                                          CoverageOptions = new CoverageOptions
                                                          {
                                                              Enabled = withCodeCoverage
                                                          },

                                                          CustomTestLauncher = withDebugger ? new VsDebuggerTestLauncher() : null,
                                                          TestLaunchMode = GetTestLaunchMode(openInBrowser, withDebugger),
                                                          ChutzpahSettingsFileEnvironments = settingsEnvironments
                                                      };
                                    var result = testRunner.RunTests(filePaths, options, runnerCallback);

                                    if (result.CoverageObject != null)
                                    {
                                        var path = CoverageOutputGenerator.WriteHtmlFile(Path.Combine(solutionDir, Constants.CoverageHtmlFileName), result.CoverageObject);
                                        processHelper.LaunchFileInBrowser(path);
                                    }
                                }
                                catch (Exception e)
                                {
                                    Logger.Log("Error while running tests", "ChutzpahPackage", e);
                                }
                                finally
                                {
                                    testingInProgress = false;
                                }
                            });
                    }
                }
            }
        }
示例#36
0
        public OpetongMainView(IEventAggregator aggregator,
                               TestOptions test,
                               OpetongVMData model
                               )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _deckGPile     = new BaseDeckWPF <RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();
            _score         = new ScoreBoardWPF();
            _playerHandWPF = new BaseHandWPF <RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();

            _tempG = new TempRummySetsWPF <EnumSuitList, EnumColorList, RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();
            _mainG = new MainRummySetsWPF <EnumSuitList, EnumColorList, RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard>, RummySet, SavedSet>();
            _poolG = new CardBoardWPF <RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();


            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(OpetongMainViewModel.RestoreScreen)
                };
            }


            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_deckGPile);
            otherStack.Children.Add(_poolG);
            _poolG.HorizontalAlignment = HorizontalAlignment.Left;
            _poolG.VerticalAlignment   = VerticalAlignment.Top;
            _tempG.Height = 350;
            otherStack.Children.Add(_tempG);
            var button = GetGamingButton("Lay Down Single Set", nameof(OpetongMainViewModel.PlaySetAsync));

            otherStack.Children.Add(button);
            mainStack.Children.Add(otherStack);
            _score.AddColumn("Cards Left", true, nameof(OpetongPlayerItem.ObjectCount)); //very common.
            _score.AddColumn("Sets Played", true, nameof(OpetongPlayerItem.SetsPlayed));
            _score.AddColumn("Score", true, nameof(OpetongPlayerItem.TotalScore));
            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(OpetongMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(OpetongMainViewModel.Status));
            firstInfo.AddRow("Instructions", nameof(OpetongMainViewModel.Instructions));

            StackPanel finalStack = new StackPanel();

            finalStack.Children.Add(_score);
            finalStack.Children.Add(firstInfo.GetContent);
            otherStack.Children.Add(finalStack);
            mainStack.Children.Add(_playerHandWPF);
            mainStack.Children.Add(_mainG);


            _deckGPile.Margin = new Thickness(5, 5, 5, 5);



            if (restoreP != null)
            {
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
 public TestDto()
 {
     Options = new TestOptions();
 }
示例#38
0
        public Rummy500MainView(IEventAggregator aggregator,
                                TestOptions test,
                                Rummy500VMData model
                                )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _deckGPile            = new BaseDeckWPF <RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();
            _score                = new ScoreBoardWPF();
            _playerHandWPF        = new BaseHandWPF <RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();
            _playerHandWPF.Margin = new Thickness(5, 5, 5, 5);
            _playerHandWPF.HorizontalAlignment = HorizontalAlignment.Stretch;
            _discardRummy = new BaseHandWPF <RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();
            _mainG        = new MainRummySetsWPF <EnumSuitList, EnumColorList, RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard>, RummySet, SavedSet>();


            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(Rummy500MainViewModel.RestoreScreen)
                };
            }
            Grid finalGrid = new Grid();

            AddAutoColumns(finalGrid, 1);
            AddLeftOverColumn(finalGrid, 1);
            AddControlToGrid(finalGrid, mainStack, 0, 1);
            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_deckGPile);
            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(Rummy500MainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(Rummy500MainViewModel.Status));

            _score.AddColumn("Cards Left", false, nameof(Rummy500PlayerItem.ObjectCount)); //very common.
            _score.AddColumn("Points Played", false, nameof(Rummy500PlayerItem.PointsPlayed));
            _score.AddColumn("Cards Played", false, nameof(Rummy500PlayerItem.CardsPlayed));
            _score.AddColumn("Score Current", false, nameof(Rummy500PlayerItem.CurrentScore));
            _score.AddColumn("Score Total", false, nameof(Rummy500PlayerItem.TotalScore));
            otherStack.Children.Add(_score);
            otherStack.Children.Add(firstInfo.GetContent);
            mainStack.Children.Add(_playerHandWPF);
            Button button;

            button = GetGamingButton("Discard Current", nameof(Rummy500MainViewModel.DiscardCurrentAsync));
            otherStack.Children.Add(button);
            button = GetGamingButton("Create New Rummy Set", nameof(Rummy500MainViewModel.CreateSetAsync));
            otherStack.Children.Add(button);
            mainStack.Children.Add(otherStack);
            _mainG.Divider = 1.3;
            _mainG.Height  = 550; // i think
            mainStack.Children.Add(_mainG);
            _discardRummy.Divider             = 1.7;
            _discardRummy.HandType            = HandObservable <RegularRummyCard> .EnumHandList.Vertical;
            _discardRummy.HorizontalAlignment = HorizontalAlignment.Left;
            _discardRummy.VerticalAlignment   = VerticalAlignment.Stretch;
            AddControlToGrid(finalGrid, _discardRummy, 0, 0);
            _deckGPile.Margin = new Thickness(5, 5, 5, 5);



            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = finalGrid;
        }
        public void ConvertActivityWithRecipient_ThrowException()
        {
            _activity.Recipient = null;

            Assert.Throws <ValidationException>(() => ToWhatsAppInfobipConverter.Convert(_activity, TestOptions.Get()));
        }
        public FlinchMainView(IEventAggregator aggregator,
                              TestOptions test,
                              FlinchVMData model
                              )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _deckGPile             = new BaseDeckWPF <FlinchCardInformation, FlinchGraphicsCP, CardGraphicsWPF>();
            _score                 = new ScoreBoardWPF();
            _playerHandWPF         = new BaseHandWPF <FlinchCardInformation, FlinchGraphicsCP, CardGraphicsWPF>();
            _publicGraphics        = new PublicPilesWPF();
            _publicGraphics.Width  = 700;
            _publicGraphics.Height = 500;
            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(FlinchMainViewModel.RestoreScreen)
                };
            }


            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_deckGPile);
            otherStack.Children.Add(_publicGraphics);
            mainStack.Children.Add(otherStack);
            StackPanel tempStack = new StackPanel();
            var        thisLabel = GetDefaultLabel();

            thisLabel.Text = "Cards To Reshuffle";
            tempStack.Children.Add(thisLabel);
            otherStack.Children.Add(tempStack);
            thisLabel = GetDefaultLabel();
            thisLabel.SetBinding(TextBlock.TextProperty, nameof(FlinchMainViewModel.CardsToShuffle));
            tempStack.Children.Add(thisLabel);
            _score.AddColumn("In Stock", false, nameof(FlinchPlayerItem.InStock));
            int x;

            for (x = 1; x <= 5; x++) //has to change for flinch.
            {
                var thisStr = "Discard" + x;
                _score.AddColumn(thisStr, false, thisStr);
            }
            _score.AddColumn("Stock Left", false, nameof(FlinchPlayerItem.StockLeft));
            _score.AddColumn("Cards Left", false, nameof(FlinchPlayerItem.ObjectCount)); //very common.
            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(FlinchMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(FlinchMainViewModel.Status));
            otherStack.Children.Add(_score);
            Button endButton = GetGamingButton("End Turn", nameof(FlinchMainViewModel.EndTurnAsync));

            endButton.HorizontalAlignment = HorizontalAlignment.Left;
            endButton.VerticalAlignment   = VerticalAlignment.Top;
            otherStack.Children.Add(endButton);
            otherStack.Children.Add(firstInfo.GetContent);
            mainStack.Children.Add(_playerHandWPF);
            ParentSingleUIContainer parent = new ParentSingleUIContainer()
            {
                Name = nameof(FlinchMainViewModel.PlayerPilesScreen)
            };

            mainStack.Children.Add(parent);


            _deckGPile.Margin = new Thickness(5, 5, 5, 5);



            if (restoreP != null)
            {
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
        public async void SkipNotificationIfAdminEmailIsNotSpecified()
        {
            var mediator = new Mock<IMediator>();
            var logger = Mock.Of<ILogger<NotifyAdminForUserUnenrolls>>();

            var options = new TestOptions<GeneralSettings>();
            options.Value.SiteBaseUrl = "localhost";

            var notification = new VolunteerSignedUpNotification
            {
                UserId = Context.Users.First().Id,
                TaskId = Context.Tasks.Skip(1).First().Id
            };

            var target = new NotifyAdminForSignup(Context, mediator.Object, options, logger);
            await target.Handle(notification);

            mediator.Verify(x => x.SendAsync(It.IsAny<NotifyVolunteersCommand>()), Times.Never);
        }
示例#42
0
        public YahtzeeHandsDownMainView(IEventAggregator aggregator,
                                        TestOptions test,
                                        YahtzeeHandsDownVMData model
                                        )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _deckGPile     = new BaseDeckWPF <YahtzeeHandsDownCardInformation, YahtzeeHandsDownGraphicsCP, CardGraphicsWPF>();
            _discardGPile  = new BasePileWPF <YahtzeeHandsDownCardInformation, YahtzeeHandsDownGraphicsCP, CardGraphicsWPF>();
            _score         = new ScoreBoardWPF();
            _playerHandWPF = new BaseHandWPF <YahtzeeHandsDownCardInformation, YahtzeeHandsDownGraphicsCP, CardGraphicsWPF>();
            _combo1        = new ComboHandWPF();
            _chance1       = new ChanceSinglePileWPF();

            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(YahtzeeHandsDownMainViewModel.RestoreScreen)
                };
            }


            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_deckGPile);
            otherStack.Children.Add(_discardGPile); // can reposition or not even have as well.

            _chance1.Margin = new Thickness(5, 5, 5, 5);
            _chance1.HorizontalAlignment = HorizontalAlignment.Left;
            _chance1.VerticalAlignment   = VerticalAlignment.Top;
            otherStack.Children.Add(_chance1);
            mainStack.Children.Add(otherStack);
            _score.AddColumn("Cards Left", true, nameof(YahtzeeHandsDownPlayerItem.ObjectCount)); //very common.
            _score.AddColumn("Total Score", true, nameof(YahtzeeHandsDownPlayerItem.TotalScore));
            _score.AddColumn("Won Last Round", true, nameof(YahtzeeHandsDownPlayerItem.WonLastRound));
            _score.AddColumn("Score Round", true, nameof(YahtzeeHandsDownPlayerItem.ScoreRound));
            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(YahtzeeHandsDownMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(YahtzeeHandsDownMainViewModel.Status));
            mainStack.Children.Add(_playerHandWPF);
            var otherButton = GetGamingButton("Go Out", nameof(YahtzeeHandsDownMainViewModel.GoOutAsync));

            mainStack.Children.Add(otherButton);
            var endButton = GetGamingButton("End Turn", nameof(YahtzeeHandsDownMainViewModel.EndTurnAsync));

            endButton.HorizontalAlignment = HorizontalAlignment.Left;
            mainStack.Children.Add(endButton);
            mainStack.Children.Add(firstInfo.GetContent);
            mainStack.Children.Add(_score);
            otherStack             = new StackPanel();
            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(mainStack);
            _combo1.HandType = HandObservable <ComboCardInfo> .EnumHandList.Vertical;
            otherStack.Children.Add(_combo1);

            _deckGPile.Margin = new Thickness(5, 5, 5, 5);

            _discardGPile.Margin = new Thickness(5, 5, 5, 5);


            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = otherStack;
        }
 private static TestOptions<GeneralSettings> GetSettings()
 {
     var options = new TestOptions<GeneralSettings>();
     options.Value.SiteBaseUrl = "localhost";
     return options;
 }
        public FiveCrownsMainView(IEventAggregator aggregator,
                                  TestOptions test,
                                  FiveCrownsVMData model
                                  )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _deckGPile     = new BaseDeckXF <FiveCrownsCardInformation, FiveCrownsGraphicsCP, CardGraphicsXF>();
            _discardGPile  = new BasePileXF <FiveCrownsCardInformation, FiveCrownsGraphicsCP, CardGraphicsXF>();
            _score         = new ScoreBoardXF();
            _playerHandWPF = new BaseHandXF <FiveCrownsCardInformation, FiveCrownsGraphicsCP, CardGraphicsXF>();
            _tempG         = new TempRummySetsXF <EnumSuitList, EnumColorList, FiveCrownsCardInformation, FiveCrownsGraphicsCP, CardGraphicsXF>();
            _mainG         = new MainRummySetsXF <EnumSuitList, EnumColorList, FiveCrownsCardInformation, FiveCrownsGraphicsCP, CardGraphicsXF, PhaseSet, SavedSet>();

            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(FiveCrownsMainViewModel.RestoreScreen));
            }

            StackLayout otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_deckGPile);
            otherStack.Children.Add(_discardGPile);                                         // can reposition or not even have as well.
            _score.AddColumn("Cards Left", true, nameof(FiveCrownsPlayerItem.ObjectCount)); //very common.
            _score.AddColumn("Current Score", true, nameof(FiveCrownsPlayerItem.CurrentScore));
            _score.AddColumn("Total Score", true, nameof(FiveCrownsPlayerItem.TotalScore));
            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

            firstInfo.AddRow("Turn", nameof(FiveCrownsMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(FiveCrownsMainViewModel.Status));
            firstInfo.AddRow("Up To", nameof(FiveCrownsMainViewModel.UpTo));


            Grid finalGrid = new Grid();

            AddAutoRows(finalGrid, 1);
            AddLeftOverRow(finalGrid, 1);
            Grid firstGrid = new Grid();

            AddLeftOverColumn(firstGrid, 40);
            AddAutoColumns(firstGrid, 1);
            AddLeftOverColumn(firstGrid, 15);
            AddLeftOverColumn(firstGrid, 30);

            var thisBut = GetSmallerButton("Lay Down", nameof(FiveCrownsMainViewModel.LayDownSetsAsync));


            AddControlToGrid(firstGrid, otherStack, 0, 1);
            StackLayout firstStack = new StackLayout();

            firstStack.Children.Add(_playerHandWPF);
            StackLayout secondStack = new StackLayout();

            secondStack.Orientation = StackOrientation.Horizontal;
            firstStack.Children.Add(secondStack);
            firstStack.Children.Add(thisBut);
            thisBut = GetSmallerButton("Back", nameof(FiveCrownsMainViewModel.Back));
            firstStack.Children.Add(thisBut);

            AddControlToGrid(firstGrid, firstStack, 0, 0);
            AddControlToGrid(firstGrid, _score, 0, 3);
            AddControlToGrid(finalGrid, firstGrid, 0, 0);
            AddControlToGrid(firstGrid, firstInfo.GetContent, 0, 2);
            _tempG.Divider = 1.1;
            StackLayout thirdStack = new StackLayout();

            thirdStack.Orientation = StackOrientation.Horizontal;
            thirdStack.Children.Add(_tempG);
            thirdStack.Children.Add(_mainG);
            AddControlToGrid(finalGrid, thirdStack, 1, 0); // i think
            _deckGPile.Margin = new Thickness(5, 5, 5, 5);

            _discardGPile.Margin = new Thickness(5, 5, 5, 5);

            if (restoreP != null)
            {
                otherStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = finalGrid;
        }
示例#45
0
 private void RunTests(IEnumerable<string> filePaths, bool withCodeCoverage)
 {
     if (!testingInProgress)
     {
         lock (syncLock)
         {
             if (!testingInProgress)
             {
                 dte.Documents.SaveAll();
                 var solutionDir = Path.GetDirectoryName(dte.Solution.FullName);
                 testingInProgress = true;
                 Task.Factory.StartNew(
                     () =>
                     {
                         try
                         {
                             var options = new TestOptions
                                               {
                                                   TestFileTimeoutMilliseconds = Settings.TimeoutMilliseconds,
                                                   MaxDegreeOfParallelism = Settings.MaxDegreeOfParallelism,
                                                   CoverageOptions = new CoverageOptions
                                                   {
                                                       Enabled = withCodeCoverage
                                                   }
                                               };
                             var result = testRunner.RunTests(filePaths, options, runnerCallback);
                             if (withCodeCoverage && result.CoverageObject != null)
                             {
                                 var path = CoverageOutputGenerator.WriteHtmlFile(solutionDir, result.CoverageObject);
                                 processHelper.LaunchFileInBrowser(path);
                             }
                         }
                         catch (Exception e)
                         {
                             Logger.Log("Error while running tests", "ChutzpahPackage", e);
                         }
                         finally
                         {
                             testingInProgress = false;
                         }
                     });
             }
         }
     }
 }