Ejemplo n.º 1
0
 public IConfiguration GetDriverConfig(TestTarget target)
 {
     IConfigurationRoot config = GetConfigurationRoot();
     //create a IConfiguration using DefaultConfig. Create your own if needed but first explore the options in Microsoft's ConfigurationBuilder
     var configModel = new DefaultConfig(target, config);
     return configModel;
 }
Ejemplo n.º 2
0
 protected IWebDriver VerifyToContinue(Func<TestTarget, IWebDriver> factoryFunc, TestTarget target)
 {
     var driver = factoryFunc.Invoke(target);
     if (driver == null)
         throw new NullReferenceException("driver not found for environment: " + target.ToString());
     return driver;
 }
Ejemplo n.º 3
0
 public static IWebDriver Create(TestTarget browser, out IConfiguration defaultConfig)
 {
     var config = GetDriverConfig(browser);
     config.CurrentBrowser = browser;
     defaultConfig = config;
     return Create(config);
 }
		public void Init()
		{
			Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			// set from string array
			string[] valstrings = new string[] { "abc", "xyz" };
			validatorStringArray = new SetValidator(valstrings);
			validatorStringArray.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));

			// set from strings
			validatorStrings = new SetValidator("abc", "xyz");
			validatorStrings.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));

			// set from enum
			validatorEnum = new SetValidator(typeof(System.DayOfWeek));
			validatorEnum.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));

			// set from flags enum
			validatorFlagsEnum = new SetValidator(typeof(System.AttributeTargets));
			validatorFlagsEnum.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));

			validatorNumbers = new SetValidator(0, 100, -1);
			validatorNumbers.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("NumberField"));

			target = new TestTarget();
		}
Ejemplo n.º 5
0
        public void Test()
        {

            //编译时校验绑定
            var t = new TestTarget();
            var rs = NLite.Validation.Validator.Validate<TestTarget>(t);
            Assert.IsFalse(rs.IsValid);

            //松耦合的编译时校验绑定(通过MetadataTypeAttribute)
            var t2 = new TestTarget2();
            var rs2 = NLite.Validation.Validator.Validate<TestTarget2>(t2);
            Assert.IsFalse(rs2.IsValid);

            //更松耦合的运行时关联校验绑定(通过EntityValidator)
            Console.WriteLine(typeof(TestTarget2Metadata).FullName);
            var t3 = new TestTarget3();
            var rs3 = NLite.Validation.Validator.Validate<TestTarget3>(t3);
            Assert.IsFalse(rs3.IsValid);

            //最灵活的运行时关联校验绑定(通过手工注册绑定)
            Validator.Register<TestTarget4,TestTarget2Metadata>();
            var t4 = new TestTarget4();
            var rs4 = NLite.Validation.Validator.Validate<TestTarget4>(t4);
            Assert.IsFalse(rs4.IsValid);
        }
Ejemplo n.º 6
0
        public TestResult RunTest(TestTarget test, RestClient client, string testCase, string token, string clientID)
        {
            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
            TestTargetTestCases tc         = test.TestCases.FirstOrDefault(x => x.name == testCase);
            TestResult          testResult = new TestResult();

            var request = GetTargetRestRequest(test, tc, token, clientID);
            var res     = client.Execute(request);

            testResult.Response = res;
            testResult.TestName = test.Name;
            testResult.Status   = testResult.Response.StatusCode == (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), tc.resultCode.ToString()) ? "PASSED" : "FAILED";

            TestResults.Add(testResult);

            Logger.Information($"------------------------------------------------------");
            Logger.Information($"Test Name: {testResult.TestName} ");
            Logger.Information($"Test Case: {tc.name} ");
            Logger.Information($"Test status code: {testResult.Response.StatusCode} ");
            if (testResult.Status == "PASSED")
            {
                Logger.Information($"Test Result: {testResult.Status}");
            }
            else
            {
                Logger.Error($"Test Result: {testResult.Status}");
            }


            return(testResult);
        }
Ejemplo n.º 7
0
        public void CalculateLoan_Ydelse()
        {
            TestTarget.Init(LoanSettings);

            TestTarget.CalculateYdelse();

            Assert.AreEqual(ExpectedValue.Ydelse, TestTarget.LoanCalculations.Ydelse, "Ydelse");
        }
Ejemplo n.º 8
0
        public void Init()
        {
            Thread.CurrentThread.CurrentCulture       =
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

            validator = new IntegerValidator();
            target    = new TestTarget();
        }
Ejemplo n.º 9
0
        protected ObjectConnection(TestTarget testTarget, string typeName)
        {
            DataTarget = testTarget.LoadFullDump();
            Runtime    = DataTarget.ClrVersions.Single().CreateRuntime();

            TestDataClrObject = FindFirstInstanceOfType(Runtime.Heap, typeName);
            TestTarget        = testTarget;
        }
        public void ShouldSetAllPropertiesIfProvided()
        {
            var fallback = new TestTarget(supportsType: true);
            var target   = new ResolvedTarget(typeof(string), fallback);

            Assert.Equal(typeof(string), target.DeclaredType);
            Assert.Same(fallback, target.FallbackTarget);
        }
Ejemplo n.º 11
0
        public void CalculateLoan_DebitorRente()
        {
            TestTarget.Init(LoanSettings);

            TestTarget.CalculateDebitorRente();

            Assert.AreEqual(ExpectedValue.DebitorRente, TestTarget.LoanCalculations.DebitorRente, "DebitorRente");
        }
 public TestsWithDependencyOnTarget(TestTarget testTarget)
 {
     if (testTarget == null)
     {
         throw new ArgumentNullException("testTarget");
     }
     this.testTarget = testTarget;
 }
Ejemplo n.º 13
0
        public void Does_Not_Inject_Into_Anonymous_Methods()
        {
            var target = new TestTarget();

            TestAspect.Reset();
            target.Method();
            Assert.Equal(3, TestAspect.beforeCalls + TestAspect.afterCalls + TestAspect.aroundCalls);
        }
Ejemplo n.º 14
0
        public static IWebDriver Create(TestTarget browser, out IConfiguration defaultConfig)
        {
            var config = GetDriverConfig(browser);

            config.CurrentBrowser = browser;
            defaultConfig         = config;
            return(Create(config));
        }
Ejemplo n.º 15
0
        public void Does_Not_Inject_Into_Anonymous_AsyncStateMashines()
        {
            var target = new TestTarget();

            TestAspect.Reset();
            target.AsyncMethod().GetAwaiter().GetResult();
            Assert.Equal(3, TestAspect.beforeCalls + TestAspect.afterCalls + TestAspect.aroundCalls);
        }
Ejemplo n.º 16
0
		public void Init()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			validator = new IntegerValidator();
			target = new TestTarget();
		}
Ejemplo n.º 17
0
        public IConfiguration GetDriverConfig(TestTarget target)
        {
            IConfigurationRoot config = GetConfigurationRoot();
            //create a IConfiguration using DefaultConfig. Create your own if needed but first explore the options in Microsoft's ConfigurationBuilder
            var configModel = new DefaultConfig(target, config);

            return(configModel);
        }
Ejemplo n.º 18
0
        public void AspectInstanceShouldContainAttributeInformation()
        {
            var instance = new TestTarget();
            var aspect   = new AttributiveAspectProvider().GetLifecycle(typeof(TestWithOnMemberBoundaryAttribute))
                           .GetAspect(JointPoints.Method(() => instance.DecoratedMethod()));

            aspect.Should().CastTo <TestWithOnMemberBoundaryAttribute>().Text.Should().Be("MyTest");
        }
Ejemplo n.º 19
0
        public void CalculateLoan_AAOP()
        {
            TestTarget.Init(LoanSettings);

            TestTarget.CalculateYdelse();
            TestTarget.CalculateAAOP();

            Assert.AreEqual(ExpectedValue.ÅOP, TestTarget.LoanCalculations.ÅOP, "ÅOP");
        }
Ejemplo n.º 20
0
        public void Init()
        {
            Thread.CurrentThread.CurrentCulture       =
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

            validator = new DecimalValidator();
            validator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));
            target = new TestTarget();
        }
Ejemplo n.º 21
0
 public IEnumerable <ISimulatorDevice> SelectDevices(TestTarget target, ILog log, bool min_version)
 {
     return(new SimulatorEnumerable {
         Simulators = this,
         Target = target,
         MinVersion = min_version,
         Log = log,
     });
 }
        public void Can_Inject_Into_Getter_Directly()
        {
            Checker.Passed = false;
            var t = new TestTarget();
            var a = t.Text;

            Assert.True(Checker.Passed);
            Checker.Passed = false;
        }
Ejemplo n.º 23
0
 private static IOneTimeTestFixture CreateOneTimeTestFixture(TestTarget target)
 {
     return(target switch
     {
         TestTarget.Unit => NoOpOneTimeTestFixture.Instance,
         TestTarget.AzureCloud => new AzureCloudPlayersOneTimeFixture(),
         TestTarget.OnPremSql => throw new NotSupportedException(),
         _ => throw new ArgumentOutOfRangeException(nameof(target), target, null)
     });
Ejemplo n.º 24
0
        public void Should_return_children_calling_GetChildren()
        {
            // arrange
            var testTarget = new TestTarget
            {
                Id   = 345,
                Data = new TestTargetData {
                    TestString = "Its a target!"
                }
            };
            var parentNode = new HierarchyNode
            {
                Id       = 23,
                LeftId   = 1,
                RightId  = 6,
                TargetId = testTarget.Id
            };
            var child1 = new HierarchyNode
            {
                Id       = 45,
                LeftId   = 2,
                RightId  = 3,
                TargetId = testTarget.Id
            };
            var child2 = new HierarchyNode
            {
                Id       = 46,
                LeftId   = 4,
                RightId  = 5,
                TargetId = testTarget.Id
            };

            var mockHierarchyDataProvider = new Mock <IHierarchyDataProvider>();

            mockHierarchyDataProvider.Setup(p => p.GetChildren(It.IsAny <HierarchyEntry>(), It.IsAny <HierarchyNode>()))
            .Returns(new List <HierarchyNode> {
                child1, child2
            });
            var mockHierarchyEntryRepository = new Mock <IHierarchyEntryRepository>();
            var mockTargetEntryRepository    = new Mock <ITargetEntryRepository>();
            var mockTargetRepository         = new Mock <ITargetRepository>();
            var mockTargetTypes = new List <Type>();
            var service         = new HierarchyService(mockHierarchyDataProvider.Object, mockHierarchyEntryRepository.Object, mockTargetEntryRepository.Object, mockTargetRepository.Object, mockTargetTypes);

            // act
            var resultNode = service.GetChildren(hierarchyEntry, parentNode);

            // assert
            Assert.That(resultNode, Is.Not.Null);
            Assert.That(resultNode.Count, Is.EqualTo(2));
            Assert.That(resultNode[0].Id, Is.EqualTo(child1.Id));
            Assert.That(resultNode[0].LeftId, Is.EqualTo(child1.LeftId));
            Assert.That(resultNode[0].RightId, Is.EqualTo(child1.RightId));
            Assert.That(resultNode[0].TargetId, Is.EqualTo(child1.TargetId));

            mockHierarchyDataProvider.Verify(p => p.GetChildren(It.IsAny <HierarchyEntry>(), It.IsAny <HierarchyNode>()));
        }
		public void Init()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			validator = new IntegerValidator();
			validator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));
			target = new TestTarget();
		}
 private ITestFixture CreateTestFixture(TestTarget target)
 {
     return(target switch
     {
         TestTarget.Unit => (ITestFixture) new UnitTestIdentityAndAccessFixture(this),
         TestTarget.AzureCloud => new AzureCloudIdentityAndAccessFixture(this),
         TestTarget.OnPremSql => throw new NotSupportedException(),
         _ => throw new ArgumentOutOfRangeException(nameof(target), target, null)
     });
Ejemplo n.º 27
0
        public void TwoInstanceOfTheSameObject_ShouldReturn_True()
        {
            var t1 = new TestTarget {
                S = "1", I = 1
            };
            var t2 = t1;

            Assert.Equal(t1, t2);
            Assert.Equal(t1, t2, new PropertiesComparer <TestTarget>());
        }
        public void GivenAuthenticationModuleProviderInitializedWithCallback_WhenOnSignedIn_ThenCallbackInvoked()
        {
            bool wasCalled = false;
            AuthenticationModuleProvider.Initialize(new Action(() => wasCalled = true));
            TestTarget target = new TestTarget();

            target.CallOnSignedIn();

            Assert.IsTrue(wasCalled);
        }
Ejemplo n.º 29
0
        private void setup()
        {
            Thread.CurrentThread.CurrentCulture       =
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

            validator = new TimeSpanValidator();

            validator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));
            target = new TestTarget();
        }
Ejemplo n.º 30
0
		private void setup(bool acceptEmptyGuid)
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			validator = new GuidValidator(acceptEmptyGuid);
			
			validator.Initialize(new CachedValidationRegistry(), typeof (TestTarget).GetProperty("TargetField"));
			target = new TestTarget();
		}
		public void SetFiresOnPropertyChangeOnLinqExp()
		{
			string propertyThatChanged = "change";
			TestTarget target = new TestTarget();
			target.PropertyChanged += (sender, e) => {
				propertyThatChanged = e.PropertyName;
			};
			target.CallSetWithLinq (); 
			Assert.IsTrue (propertyThatChanged == "MyLinqProperty");
		}
		public void ObjectValidator()
		{
			TestTarget target = new TestTarget();
			target.ItemSKUs = new string[] { "ITEM-1" };
			target.Total = 10000.00;
			Assert.IsTrue(contributor.IsValid(target, RunWhen.Everytime).HasError);

			target.Total = 10.00;
			Assert.IsFalse(contributor.IsValid(target, RunWhen.Everytime).HasError);
		}
		public void OnPropertyChangeFiresOnStringName()
		{
			string propertyThatChanged = "change";
			TestTarget target = new TestTarget();
			target.PropertyChanged += (sender, e) => {
				propertyThatChanged = e.PropertyName;
			};
			target.MyStringProperty = 1;
			Assert.IsTrue (propertyThatChanged == "MyStringProperty");
		}
Ejemplo n.º 34
0
        public void Navigate_FromHomeToTerms_TitleIsTerms(TestTarget target)
        {
            using (IDriver driver = GetDriver(target))
            {
                var homePage = Page.Create<GoogleHomePage>(driver).Go<GoogleHomePage>();
                var termsPage = homePage.TermsLink.Click();

                Assert.Equal("Google Terms of Service – Privacy & Terms – Google", termsPage.Title);
            }
        }
Ejemplo n.º 35
0
        public void Navigate_FromHomeToTerms_TitleIsTerms(TestTarget target)
        {
            using (IDriver driver = GetDriver(target))
            {
                var homePage  = Page.Create <GoogleHomePage>(driver).Go <GoogleHomePage>();
                var termsPage = homePage.TermsLink.Click();

                Assert.Equal("Google Terms of Service – Privacy & Terms – Google", termsPage.Title);
            }
        }
Ejemplo n.º 36
0
 public static TestTargetOs GetTargetOs(this TestTarget target, bool minVersion)
 {
     return(target switch {
         TestTarget.Simulator_iOS32 => new TestTargetOs(target, minVersion ? SdkVersions.MiniOSSimulator : "10.3"),
         TestTarget.Simulator_iOS64 => new TestTargetOs(target, minVersion ? SdkVersions.MiniOSSimulator : SdkVersions.MaxiOSSimulator),
         TestTarget.Simulator_iOS => new TestTargetOs(target, minVersion ? SdkVersions.MiniOSSimulator : SdkVersions.MaxiOSSimulator),
         TestTarget.Simulator_tvOS => new TestTargetOs(target, minVersion ? SdkVersions.MinTVOSSimulator : SdkVersions.MaxTVOSSimulator),
         TestTarget.Simulator_watchOS => new TestTargetOs(target, minVersion ? SdkVersions.MinWatchOSSimulator : SdkVersions.MaxWatchOSSimulator),
         _ => throw new Exception(string.Format("Invalid simulator target: {0}", target))
     });
Ejemplo n.º 37
0
        public void Executes_non_awaitable()
        {
            var target = new TestTarget();
            var method = target.GetType().GetRuntimeMethod("NonAwaitable", Array.Empty <Type>());

            var awaitable = method.InvokeAsync(target, null);

            var result = awaitable.GetAwaiter().GetResult();

            Assert.Equal("result of NonAwaitable", result);
        }
Ejemplo n.º 38
0
        public void TwoInstanceWithDifferentProperties_ShouldReturn_False()
        {
            var t1 = new TestTarget {
                S = "1", I = 1
            };
            var t2 = new TestTarget {
                S = "1A", I = 1
            };

            Assert.NotEqual(t1, t2, new PropertiesComparer <TestTarget>());
        }
		public void Init()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			validator = new GroupNotEmptyValidator("Dummy");
			validator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("Foo"));
			validator.FriendlyName = "BAR";
			validator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("Bar"));
			target = new TestTarget();
		}
Ejemplo n.º 40
0
        public void Init()
        {
            _directoryValidator = new DirectoryValidator();
            _directoryValidator.Initialize(new CachedValidationRegistry(),
                                           typeof(TestTarget).GetProperty("TargetField"));

            _filePathValidator = new FilePathValidator();
            _filePathValidator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));

            _target = new TestTarget();
        }
Ejemplo n.º 41
0
        public void Executes_valuetask_of_string()
        {
            var target = new TestTarget();
            var method = target.GetType().GetRuntimeMethod("ValueTaskOfString", Array.Empty <Type>());

            var awaitable = method.InvokeAsync(target, null);

            var result = awaitable.GetAwaiter().GetResult();

            Assert.Equal("result of ValueTask<string>", result);
        }
        public void ObjectValidator()
        {
            TestTarget target = new TestTarget();

            target.ItemSKUs = new string[] { "ITEM-1" };
            target.Total    = 10000.00;
            Assert.IsTrue(contributor.IsValid(target, RunWhen.Everytime).HasError);

            target.Total = 10.00;
            Assert.IsFalse(contributor.IsValid(target, RunWhen.Everytime).HasError);
        }
Ejemplo n.º 43
0
        public void Init()
        {
            Thread.CurrentThread.CurrentCulture       =
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

            validator = new GroupNotEmptyValidator("Dummy");
            validator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("Foo"));
            validator.FriendlyName = "BAR";
            validator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("Bar"));
            target = new TestTarget();
        }
 public bool AppliesToTarget(TestTarget target)
 {
     if (applies != null)
     {
         return(applies());
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 45
0
        public void Title_OnGoogleTermsPageNoConfig_IsGoogle(TestTarget target)
        {
            //create a driver with default configuration
            using (IDriver driver = GetDriver(target))
            {
                //create page model for test
                var termsPage = Page.Create<GoogleTermsPage>(driver).Go<GoogleTermsPage>();

                //check the titles match
                Assert.Equal("Google Terms of Service – Privacy & Terms – Google", termsPage.Title);
            }
        }
Ejemplo n.º 46
0
        public void records_number_of_invocations()
        {
            var target = new TestTarget();
            var fooSpy = new EventSpy<EventArgs>();

            target.OnFoo += fooSpy;
            target.Foo();
            Check.That(() => fooSpy.HasBeenCalled);
            fooSpy.Then((s, e) =>
                Check.That(
                    () => Object.ReferenceEquals(s, target),
                    () => e == EventArgs.Empty));
        }
Ejemplo n.º 47
0
		public void Init()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			validator1 = new LengthValidator(5);
			validator1.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));

			validator2 = new LengthValidator(4, 6);
			validator2.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));

			target = new TestTarget();
		}
		public void HonorsRunWhen()
		{
			TestTarget target = new TestTarget();
			target.ItemSKUs = new string[] { "ITEM-1" };
			target.Total = 10000.00;
			Assert.IsTrue(contributor.IsValid(target, RunWhen.Everytime).HasError);
			Assert.IsTrue(target.ValidateOnUpdateRan);

			target = new TestTarget();
			target.ItemSKUs = new string[] { "ITEM-1" };
			target.Total = 10000.00;
			Assert.IsTrue(contributor.IsValid(target, RunWhen.Custom).HasError);
			Assert.IsFalse(target.ValidateOnUpdateRan);
		}
		public void Init()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			greaterIntValidator = new IsGreaterValidator(IsGreaterValidationType.Integer, "IntCompareField");
			greaterIntValidator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("IntTarget"));

			greaterDateValidator = new IsGreaterValidator(IsGreaterValidationType.Date, "DateCompareField");
			greaterDateValidator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("DateTarget"));

			nullableGreaterDateValidator = new IsGreaterValidator(IsGreaterValidationType.Date, "NullableDateCompareField");
			nullableGreaterDateValidator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("NullableDateTarget"));

			target = new TestTarget();
		}
		public void Init()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			validator1 = new NotSameValueValidator("15");
			validator1.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField1"));

			validator2 = new NotSameValueValidator(15);
			validator2.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField2"));

			ValidateNotSameValueAttribute attribute = new ValidateNotSameValueAttribute(typeof(Guid), Guid.Empty.ToString());
			validator3 = (NotSameValueValidator) attribute.Build();
			validator3.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField3"));

			target = new TestTarget();
		}
		public void Init()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			validator1 = new NotSameAsValidator("ComparableField1");
			validator1.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField1"));

			validator2 = new NotSameAsValidator("ComparableField2");
			validator2.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField2"));

			// Use public field instead of public property
			validator3 = new NotSameAsValidator("ComparableField3");
			validator3.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField1"));

			target = new TestTarget();
		}
Ejemplo n.º 52
0
        public void Login_And_Save_Profile_Gives_Success_Message(TestTarget target)
        {
            using (IDriver driver = GetDriver(target))
            {
                var contactPage = Page.Create<ContactPage>(driver).Go<ContactPage>();
                contactPage.FirstName.Value = "Devon";
                contactPage.LastName.Value = "Burriss";
                contactPage.Email.Value = "*****@*****.**";
                contactPage.Gender.SelectWhere(x => x.Value == "Male");
                contactPage.LeadSource.SelectWhere(x => x.Value == "A friend");
                contactPage.Skills.SelectWhere(x => int.Parse(x.Value) % 2 == 0);//select the even values
                contactPage.Message.Value = "Almost there... Casper going to click the button now.";
                contactPage.Newsletter.Click();
                bool newsletter = contactPage.Newsletter.IsChecked;
                var successPage = contactPage.SaveBtn.Click();

                var message = successPage.GetMessage();

                Assert.True(newsletter);
                Assert.Equal("Thank you.", message);
            }
        }
Ejemplo n.º 53
0
        public void Title_OnGoogleHomePageUsingConfig_IsGoogle(TestTarget target)
        {
            //build a custom config
            var config = GetDriverConfig(target);
            using (IDriver driver = GetDriver(target, config))
            {
                //create page model for test
                var homePage = Page.Create<GoogleHomePage>(driver);

                //tell browser to navigate to it
                homePage.Go<GoogleHomePage>();

                //fill a value into the text box
                homePage.SearchBox.Value = "TEST";

                //an example of interacting with the config if needed. This gets expected title from config.
                var expectedTitle = config.GetPageSetting("home").Title;

                //check the titles match
                Assert.Equal(expectedTitle, homePage.Title);
            }
        }
Ejemplo n.º 54
0
 private static IConfiguration GetDriverConfig(TestTarget target)
 {
     IConfigurationRoot config = GetConfigurationRoot();
     var configModel = new DefaultConfig(target, config);
     return configModel;
 }
 public TestsWithTraceOutput(TestTarget target)
 {
     this.target = target;
 }
Ejemplo n.º 56
0
 public DefaultConfig(TestTarget currentBrowser, IConfigurationRoot configRoot)
 {
     CurrentBrowser = currentBrowser;
     _configRoot = configRoot;
 }
Ejemplo n.º 57
0
 public void SetUp()
 {
     _Target = new TestTarget(13);
 }
 public TestLoggingConfiguration()
 {
     Target = new TestTarget();
     LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, Target));
 }
Ejemplo n.º 59
0
 protected IDriver GetDriver(TestTarget target, IConfiguration configuration)
 {
     //here we creating an IDriver using Selenium as the implementation with configuration
     return VerifyToContinue((t) => DriverFactory.Create(configuration), target).ToIDriver(configuration);
 }
Ejemplo n.º 60
0
 protected IDriver GetDriver(TestTarget target)
 {
     IConfiguration defaultConfig = null;
     //here we creating an IDriver using Selenium as the implementation
     return VerifyToContinue((t) => DriverFactory.Create(target, out defaultConfig), target).ToIDriver(defaultConfig);
 }