protected void TestEventMessageProperties <T>(AssertHelper assertHelper, IEventMessage <T> message, long timestamp, int productId, string eventId, long?requestId) where T : class, ISportEvent
 {
     TestMessageProperties(assertHelper, message, timestamp, productId);
     assertHelper.IsNotNull(() => message.Event);
     assertHelper.AreEqual(() => message.Event.Id.ToString(), eventId);
     assertHelper.AreEqual(() => message.RequestId, requestId);
 }
Ejemplo n.º 2
0
        private static void TestCompetitors(IReadOnlyList <TeamCompetitorDTO> competitors, IReadOnlyCollection <teamCompetitor> comps, AssertHelper assertHelper)
        {
            assertHelper.AreEqual(() => competitors.Count, comps.Count);
            foreach (var c in comps)
            {
                var m = competitors.FirstOrDefault(x => x.Id.ToString() == c.id);
                Assert.IsNotNull(m, $"Missing ITeamCompetitor with id: {c.id}.");
                assertHelper.AreEqual(() => m.Id.ToString(), c.id);
                assertHelper.AreEqual(() => m.Qualifier, c.qualifier);
                assertHelper.AreEqual(() => m.Name, c.name);
                assertHelper.AreEqual(() => m.Abbreviation, c.abbreviation);
                assertHelper.AreEqual(() => m.CountryName, c.country);
                assertHelper.AreEqual(() => m.State, c.state);
                assertHelper.AreEqual(() => m.IsVirtual, c.virtualSpecified && c.@virtual);

                if (c.divisionSpecified)
                {
                    assertHelper.AreEqual(() => m.Division.Value, c.division);
                }
                else
                {
                    assertHelper.AreEqual(() => m.Division.HasValue, false);
                }
            }
        }
        private static bool CompareMarketOutcomeSettlement(IReadOnlyList <IOutcomeSettlement> marketOutcomeSettlement, betSettlementMarketOutcome[] betOutcomes, AssertHelper assertHelper)
        {
            var mos = marketOutcomeSettlement.ToList();

            if (mos.Count == 0 && betOutcomes.Length == 0)
            {
                return(true);
            }

            foreach (var b in betOutcomes)
            {
                foreach (var m in mos)
                {
                    if (b.id == m.Id)
                    {
                        assertHelper.AreEqual(() => m.Id, b.id);
                        assertHelper.AreEqual(() => m.DeadHeatFactor, b.dead_heat_factorSpecified
                                                                ? (double?)b.dead_heat_factor
                                                                : null);
                        assertHelper.AreEqual(() => m.Result, b.result == 1);

                        var voidFactor = (VoidFactor?)MessageMapperHelper.GetVoidFactor(b.void_factorSpecified, b.void_factor);
                        assertHelper.AreEqual(() => m.VoidFactor, voidFactor);

                        break;
                    }
                }
            }

            return(true);
        }
 private void TestEntityValues(IFixtureChange <ICompetition> entity, fixture_change record, AssertHelper assertHelper)
 {
     TestEventMessageProperties(assertHelper, entity, record.timestamp, record.product, record.event_id, record.RequestId);;
     assertHelper.AreEqual(() => (int)entity.ChangeType, record.change_typeSpecified
                                                         ? (int?)record.change_type
                                                         : (int)FixtureChangeType.OTHER);
     assertHelper.AreEqual(() => entity.NextLiveTime, record.next_live_timeSpecified
                                                         ? (long?)record.next_live_time
                                                         : null);
     assertHelper.AreEqual(() => entity.StartTime, record.start_time);
 }
        private void TestEntityValues(IBetSettlement <ICompetition> entity, bet_settlement record, AssertHelper assertHelper)
        {
            assertHelper.AreEqual(() => entity.Event.Id.ToString(), record.event_id);
            var rProduct = TestProducerManager.Create().Get(record.product);

            assertHelper.AreEqual(() => entity.Producer, rProduct);
            assertHelper.AreEqual(() => entity.RequestId, record.request_idSpecified
                                                                ? (long?)record.request_id
                                                                : null);
            assertHelper.AreEqual(() => entity.Timestamps.Created, record.timestamp);

            TestMarketOutcomes(entity.Markets.ToList(), record.outcomes, assertHelper);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Runs an action and catches an expected exception.
        /// </summary>
        /// <typeparam name="T">The type of exception that will be caught. All others will be rethrown.</typeparam>
        /// <param name="action">Action to generate the exception</param>
        /// <param name="message">Optional string to compare the exception message to.</param>
        /// <returns>Returns the expected exception so further testing on exception properties
        /// can be performed.</returns>
        /// <example>
        ///     //Define the action that will throw the expected exception
        ///     Action action = () => { throw new ArgumentNullException("paramname"); };
        ///     //Call the helper and pass in the action
        ///     var ex = ActionExtensions.AssertException<ArgumentNullException>(action);
        ///     //The helper will check the exception type but you can do more analysis if you need to
        ///     Assert.AreEqual("paramname", ex.ParamName);
        /// </example>
        public static T AssertException <T>(this Action action, string message = null)
            where T : Exception
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            T exception = null;

            try
            {
                action();
            }
            catch (T ex)
            {
                //Verify that the types are equal and not just assignable
                if (ex.GetType() != typeof(T))
                {
                    throw;
                }
                exception = ex;
            }

            AssertHelper.IsNotNull(exception, "Exception of type {0} should be thrown. No exception was thrown.", typeof(T));

            if (message != null)
            {
                AssertHelper.AreEqual(message.Trim(), exception.Message.Trim());
            }

            return(exception);
        }
Ejemplo n.º 7
0
        public void ThenListOfByGroupTemplateShouldBeDisplayed()
        {
            String ActualData = ObjectRepository.Driver.FindElement(By.XPath("//td[contains(text(),'Primustest')]")).Text.ToString();

            Console.WriteLine(ActualData);
            AssertHelper.AreEqual("Primustest", ActualData);
        }
Ejemplo n.º 8
0
        public void ThenListOfByNameTemplateShouldBeDisplayed()
        {
            String ActualData = ObjectRepository.Driver.FindElement(By.XPath("//td[contains(text(),NameEmailTemplate)]")).Text.ToString();

            Console.WriteLine(ActualData);
            AssertHelper.AreEqual(NameEmailTemplate, ActualData);
        }
        public void ShouldReceiveInputValues_WhenInputsActionsEnabled()
        {
            var keyboard = InputSystem.AddDevice <Keyboard>();
            var inputs   = new FirstPersonInputs(new FirstPersonInputActions());

            inputs.Enable();

            Press(keyboard.wKey);
            Assert.That(inputs.Move, Is.EqualTo(new Vector2(0f, 1f)));
            Release(keyboard.wKey);

            Press(keyboard.sKey);
            Assert.That(inputs.Move, Is.EqualTo(new Vector2(0f, -1f)));
            Release(keyboard.sKey);

            Press(keyboard.aKey);
            Assert.That(inputs.Move, Is.EqualTo(new Vector2(-1f, 0f)));
            Release(keyboard.aKey);

            Press(keyboard.dKey);
            Assert.That(inputs.Move, Is.EqualTo(new Vector2(1f, 0f)));
            Release(keyboard.dKey);

            Press(keyboard.wKey);
            Press(keyboard.aKey);

            var expected = new Vector2(-1f, 1f).normalized;

            AssertHelper.AreEqual(inputs.Move, expected, 0.0001f);

            Release(keyboard.wKey);
            Release(keyboard.aKey);
        }
Ejemplo n.º 10
0
        public void ValidateInformationIcon()
        {
            Assert.That(messageBox.Displayed);
            string expectedMessage = "This calculator has an age limit of 64 years old as you need to be under the age of 65 to join KiwiSaver.";

            AssertHelper.AreEqual(expectedMessage, actualMessage);
        }
Ejemplo n.º 11
0
        public void Search(string title, int?page)
        {
            // Arrange
            var api      = new OMDbApiMock();
            var itemList = new List <ApiSearchDto>
            {
                TestHelper.GetSearchDto("1"),
                TestHelper.GetSearchDto("2"),
                TestHelper.GetSearchDto("3")
            };

            api.InitSearchMock(itemList);

            // Act
            var result = api.Search(title, page);

            // Assert
            var expected = new ApiSearchRootDto()
            {
                Search = new List <ApiSearchDto>()
                {
                    TestHelper.GetSearchDto(title)
                },
                Response     = true,
                TotalResults = 1
            };

            AssertHelper.AreEqual(expected, result);
        }
Ejemplo n.º 12
0
        public void Test_Linq_Take_MoreThanCollectionSize()
        {
            IList <int> source = new[] { 1, 2, 3 };
            IList <int> dest   = source.Take(5).ToArray();

            AssertHelper.AreEqual(3, () => dest.Count);
        }
Ejemplo n.º 13
0
        public void FillFormwithMessage(int i)
        {
            var    path     = Directory.GetCurrentDirectory();
            string fileName = path + "\\Test\\Data\\TestData.xlsx";

            //   ExcelHelper eat = new ExcelHelper(fileName);
            //  string strWorksheetName = eat.getExcelSheetName(fileName, 1);
            // ComboBoxHelper.SelectInDropDownByText(SubjectHeading, eat.GetCellData(strWorksheetName, "SubjectHeading", i));
            ComboBoxHelper.SelectInDropDownByText(SubjectHeading, "Customer service1");
            Thread.Sleep(5000);
            // TextBoxHelper.ClearandTypeinTextBox(Emailaddress, eat.GetCellData(strWorksheetName, "Email address", i));
            TextBoxHelper.ClearandTypeinTextBox(Emailaddress, "*****@*****.**");
            Thread.Sleep(5000);
            //TextBoxHelper.ClearandTypeinTextBox(OrderReference, eat.GetCellData(strWorksheetName, "Order Reference", i));
            TextBoxHelper.ClearandTypeinTextBox(OrderReference, "AAAA");
            Thread.Sleep(5000);
            TextBoxHelper.ClearandTypeinTextBox(Message, "This is with Reference to My Order");
            Thread.Sleep(5000);
            Send.Click();
            Thread.Sleep(5000);
            string ConfirmationMsg = ConfirmationMessage.Text;

            Thread.Sleep(5000);
            AssertHelper.AreEqual(ConfirmationMsg, "Your message has been successfully sent to our team.");
            Thread.Sleep(5000);
        }
Ejemplo n.º 14
0
        public void SingleNumberGeneratorIEnumerableChan()
        {
            var c = new Chan <int>();

            var t = new Thread(() =>
            {
                for (var i = 0; i < 10; i++)
                {
                    c.Send(i);
                }
                c.Close();
            });

            t.IsBackground = true;
            t.Start();

            var list = new List <int>();

            foreach (var i in (IEnumerable)c)
            {
                list.Add((int)i);
            }

            AssertHelper.AreEqual(new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, list);
        }
Ejemplo n.º 15
0
        public void GetTitleOfThePage()
        {
            string expectedTitle = "Search - My Store";
            string actualTitle   = ObjectRepository.Driver.Title;

            AssertHelper.AreEqual(actualTitle, expectedTitle);
            Logger.Info(" Page Title Verified");
        }
        public static void AssertAreEqual <T>(this DataRow dataRow, string columnName, T expectedValue, string rowIdentifier = null)
        {
            dataRow.ThrowIfNull("dataRow");
            columnName.ThrowIfNullOrWhiteSpace("columnName");

            AssertHelper.AreEqual <T>(expectedValue, dataRow.Field <T>(columnName)
                                      , string.Format("{0}.{1} has an incorrect value.{2}", dataRow.Table.TableName, columnName, rowIdentifier ?? string.Empty));
        }
        private void TestMarketOutcomes(IReadOnlyList <IMarketWithSettlement> markets, betSettlementMarket[] bets, AssertHelper assertHelper)
        {
            foreach (var b in bets)
            {
                var m = FindMarketWithSettlementByIdAndSpecifier(markets, b.id, b.specifiers);

                assertHelper.AreEqual(() => m.Id, b.id);
                var marketSpecifiersMatch        = CompareMarketSpecifiers(m.Specifiers, b.specifiers);
                var marketOutcomeSettlementMatch = CompareMarketOutcomeSettlement(m.OutcomeSettlements.ToList(), b.Items, assertHelper);
                assertHelper.AreEqual(() => m.Specifiers, marketSpecifiersMatch
                                                            ? m.Specifiers
                                                            : null);
                assertHelper.AreEqual(() => m.OutcomeSettlements, marketOutcomeSettlementMatch
                                                            ? m.OutcomeSettlements
                                                            : null);
            }
        }
        public void WhenUserEntersOTPAndClickOnLOGIN()
        {
            string pTitle = "Complete Login";

            AssertHelper.AreEqual(pTitle, PropertiesCollection.Driver.Title);
            LoginPage lPage = new LoginPage();

            lPage.CaptureOTP(username);
        }
Ejemplo n.º 19
0
        public void PrimeSieve()
        {
            var generate = new Action <Chan <int> >(cgen =>
            {
                while (true)
                {
                    for (var i = 2; ; i++)
                    {
                        cgen.Send(i);
                    }
                }
                // ReSharper disable once FunctionNeverReturns
            });

            var filter = new Action <Chan <int>, Chan <int>, int>((cin, cout, prime) =>
            {
                while (true)
                {
                    var i = cin.Receive();
                    if (i % prime != 0)
                    {
                        cout.Send(i);
                    }
                }
                // ReSharper disable once FunctionNeverReturns
            });

            var ch = new Chan <int>();

            var generateCh     = ch;
            var threadGenerate = new Thread(() => generate(generateCh));

            threadGenerate.IsBackground = true;
            threadGenerate.Start();

            var list = new List <int>();

            for (var i = 0; i < 10; i++)
            {
                var prime = ch.Receive();
                list.Add(prime);

                var ch0 = ch;
                var ch1 = new Chan <int>();

                var threadFilter = new Thread(() => filter(ch0, ch1, prime));
                threadFilter.IsBackground = true;
                threadFilter.Start();

                ch = ch1;
            }

            AssertHelper.AreEqual(new[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 }, list);
        }
Ejemplo n.º 20
0
        private void TestEntityValues(IBetStop <ICompetition> entity, bet_stop record, AssertHelper assertHelper)
        {
            TestEventMessageProperties(assertHelper, entity, record.timestamp, record.product, record.event_id, record.RequestId);

            var recordGroupsCount = record.groups?.Split(new[] { SdkInfo.MarketGroupsDelimiter }, StringSplitOptions.RemoveEmptyEntries).Length ?? 0;
            var entityGroupsCount = entity.Groups?.Count() ?? 0;

            Assert.AreEqual(entityGroupsCount, recordGroupsCount);
            //assertHelper.AreEqual(() => entityGroupsCount, recordGroupsCount);
            assertHelper.AreEqual(() => entity.MarketStatus, MessageMapperHelper.GetEnumValue(record.market_statusSpecified, record.market_status, MarketStatus.SUSPENDED));
        }
        public void WhenUserEntersValidAndAndClickLOGIN(string Email, string Password)
        {
            LoginPage lPage = new LoginPage();

            PropertiesCollection.Driver.Manage()
            .Timeouts().ImplicitWait = TimeSpan.FromSeconds(PropertiesCollection.Config.GetElementLoadTimeOut());
            string pTitle            = "Profile Login";

            lPage.CaptureUserName(Email);
            AssertHelper.AreEqual(pTitle, PropertiesCollection.Driver.Title);
            lPage.CapturePassword(Password);
        }
Ejemplo n.º 22
0
        public void Test_ConfigurationManager_OpenFromFile_ReadFrom_Configuration_AppSettings_Settings_Indexer_Value_Works()
        {
            Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(
                new ExeConfigurationFileMap {
                ExeConfigFilename = "Custom.config"
            },
                ConfigurationUserLevel.None);

            string appSettingValue = configuration.AppSettings.Settings["MyAppSettingKey"].Value;

            AssertHelper.AreEqual("MyAppSettingValue", () => appSettingValue);
        }
        private void TestEntityValues(IOddsChange <ICompetition> entity, odds_change record, AssertHelper assertHelper)
        {
            TestEventMessageProperties(assertHelper, entity, record.timestamp, record.product, record.event_id, record.RequestId);
            assertHelper.AreEqual(() => entity.ChangeReason,
                                  MessageMapperHelper.GetEnumValue <OddsChangeReason>(record.odds_change_reason));

            if (record.odds.betstop_reasonSpecified)
            {
                assertHelper.AreEqual(() => entity.BetStopReason.Id, record.odds.betstop_reason);
            }
            else
            {
                assertHelper.IsNull(() => entity.BetStopReason);
            }

            if (record.odds.betting_statusSpecified)
            {
                assertHelper.AreEqual(() => entity.BettingStatus.Id, record.odds.betting_status);
            }
            else
            {
                assertHelper.IsNull(() => entity.BettingStatus);
            }

            if (record.odds?.market == null || record.odds.market.Length == 0)
            {
                Assert.IsNull(entity.Markets);
            }
            else
            {
                foreach (var marketRecord in record.odds.market)
                {
                    var market = FindMarket(entity.Markets, marketRecord.id, marketRecord.specifiers);
                    Assert.IsNotNull(market, $"Market with id={marketRecord.id} does not exist on mapped message");
                    TestMarketValues(market, marketRecord);
                }
            }
        }
Ejemplo n.º 24
0
    public object ListRenderGroupField(object dataItem, string groupFieldName, ref object currentGroupValue, bool updCurrentGroupVal)
    {
        var groupValue = DataBinder.Eval(dataItem, groupFieldName);

        if (AssertHelper.AreEqual(groupValue, currentGroupValue))
        {
            return(null);
        }
        if (updCurrentGroupVal)
        {
            currentGroupValue = groupValue;
        }
        return(groupValue);
    }
Ejemplo n.º 25
0
        public void BufferedChannelsSelectSendAndReceiveInGoroutine()
        {
            var c = new Chan <int>(10);

            var list = new List <int>();
            var wg   = new WaitGroup();

            wg.Add(2);

            GoFunc.Run(() =>
            {
                var doLoop = true;
                while (doLoop)
                {
                    Select
                    .CaseReceiveOk(c, (i, ok) =>
                    {
                        if (ok)
                        {
                            list.Add(i);
                        }
                        else
                        {
                            doLoop = false;
                        }
                    })
                    .NoDefault();
                }

                wg.Done();
            }, "bufferChannelsTest:receiveLoop");

            GoFunc.Run(() =>
            {
                for (var i = 0; i < 10; i++)
                {
                    Select
                    .CaseSend(c, i)
                    .NoDefault();
                }

                c.Close();
                wg.Done();
            }, "bufferedChannelsTest:sendLoop");

            wg.Wait();

            AssertHelper.AreEqual(new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, list);
        }
        public void ThenSitecoreExperiencePlatformPageShouldBeDisplayed()
        {
            Thread.Sleep(5000);

            try
            {
                AssertHelper.AreEqual(GenericHelper.GetElement(By.XPath(".//*[@class='sc-launchpad-item']/span[contains(text(), 'Content Editor')]")).Text, "Content Editor");
            }
            catch (Exception e)
            {
                Logger.Error("Exception: " + e);
                Assert.Fail("Exception" + e);
                throw;
            }
        }
 public void ThenContentEditorPageShouldBeDisplayed()
 {
     try
     {
         AssertHelper.AreEqual(GenericHelper.GetElement(By.XPath(".//*[@class='scEditorHeaderTitlePanel']/a[contains(text(), 'Home')]")).Text, "Home");
         GenericHelper.TakeScreenShot();
         ButtonHelper.ClickButton(By.XPath(".//*[@class='sc-accountInformation']/li[1]/span"));
         Thread.Sleep(1000);
     }
     catch (Exception e)
     {
         Logger.Error("Exception: " + e);
         Assert.Fail("Exception" + e);
         throw;
     }
 }
        public void ThenIShouldBeShownTheAreaBrowseSearchGrid()
        {
            try
            {
                ObjectRepository.ABpage = new AreaBrowsePage(ObjectRepository.Driver);
                AssertHelper.AreEqual(GenericHelper.GetElement(By.XPath(".//*[@id='content']/div/h1[contains(text(), 'London Bridge')]")).Text, "London Bridge");
                //Assert.IsTrue(ObjectRepository.ABpage.HasSearchGrid());
                //Assert.IsTrue(ObjectRepository.ABpage.HasSearchGrid());
                //ReportHelper.PassingTestLogger("Test Sucessful");
            }
            catch (Exception e)
            {
                Logger.Error("Exception: " + e);
                Assert.Fail("Exception" + e);
            }

            //AssertHelper.AreEqual(GenericHelper.GetElement(By.Id("prices-acc")).GetAttribute("Prices and Opening Times"), "Prices and Opening Times");
            //Assert.IsTrue(GenericHelper.IsElemetPresent(By.Id("prices-acc")));
        }
 private static void TestCompetitors(IReadOnlyList <CompetitorDTO> competitors, IReadOnlyCollection <team> comps, AssertHelper assertHelper)
 {
     assertHelper.AreEqual(() => competitors.Count, comps.Count);
     foreach (var c in comps)
     {
         var m = competitors.FirstOrDefault(x => x.Id.ToString() == c.id);
         Assert.IsNotNull(m, $"Missing ICompetitor with id: {c.id}.");
         assertHelper.AreEqual(() => m.Id.ToString(), c.id);
         assertHelper.AreEqual(() => m.Name, c.name);
         assertHelper.AreEqual(() => m.Abbreviation, c.abbreviation);
         assertHelper.AreEqual(() => m.CountryName, c.country);
         assertHelper.AreEqual(() => m.IsVirtual, c.virtualSpecified && c.@virtual);
     }
 }
Ejemplo n.º 30
0
        public void Details(string id)
        {
            // Arrange
            var api         = new OMDbApiMock();
            var detailsList = new List <ApiDetailsDto>()
            {
                TestHelper.GetDetailsDto("1"),
                TestHelper.GetDetailsDto("2"),
                TestHelper.GetDetailsDto("3"),
            };

            api.InitDetailsMock(detailsList);

            // Act
            var result = api.GetDetails(id);

            // Assert
            var expected = TestHelper.GetDetailsDto(id);

            AssertHelper.AreEqual(expected, result);
        }