Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(int, int)

Here are the examples of the csharp api Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(int, int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

583 Examples 7

19 View Source File : SimpleIocTestAutoCreation.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestAutoCreationWithFactoryForInterface()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<ITestClreplaced>(
                () => new TestClreplaced1(),
                true);

            var instances = SimpleIoc.Default.GetAllInstances<ITestClreplaced>();
            replacedert.AreEqual(1, instances.Count());

            var defaultInstance = SimpleIoc.Default.GetInstance<ITestClreplaced>();
            replacedert.AreSame(defaultInstance, instances.ElementAt(0));
        }

19 View Source File : MessengerRegisterUnregisterTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestRegisterSimpleTypes()
        {
            const string testContentString = "abcd";
            var testContentDateTime = DateTime.Now;
            const int testContentInt = 42;

            Messenger.Reset();
            Reset();

            Messenger.Default.Register<string>(this, m => ReceivedContentStringA1 = m);
            Messenger.Default.Register<DateTime>(this, m => ReceivedContentDateTime1 = m);
            Messenger.Default.Register<int>(this, m => ReceivedContentInt = m);

            replacedert.AreEqual(null, ReceivedContentStringA1);
            replacedert.AreEqual(DateTime.MinValue, ReceivedContentDateTime1);
            replacedert.AreEqual(default(int), ReceivedContentInt);

            Messenger.Default.Send(testContentString);

            replacedert.AreEqual(testContentString, ReceivedContentStringA1);
            replacedert.AreEqual(DateTime.MinValue, ReceivedContentDateTime1);
            replacedert.AreEqual(default(int), ReceivedContentInt);

            Messenger.Default.Send(testContentDateTime);

            replacedert.AreEqual(testContentString, ReceivedContentStringA1);
            replacedert.AreEqual(testContentDateTime, ReceivedContentDateTime1);
            replacedert.AreEqual(default(int), ReceivedContentInt);

            Messenger.Default.Send(testContentInt);

            replacedert.AreEqual(testContentString, ReceivedContentStringA1);
            replacedert.AreEqual(testContentDateTime, ReceivedContentDateTime1);
            replacedert.AreEqual(testContentInt, ReceivedContentInt);
        }

19 View Source File : Sessions.cs
License : MIT License
Project Creator : kfrajtak

[TestMethod]
        public void GetSessions_CurrentList()
        {
            using (HttpWebResponse response = WebRequest.Create(CommonTestSettings.WindowsApplicationDriverUrl + "/sessions").GetResponse() as HttpWebResponse)
            {
                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                JObject responseObject = JObject.Parse(responseString);
                replacedert.AreEqual(0, (int)responseObject["status"]);

                JArray capabilitiesArray = (JArray)responseObject["value"];
                replacedert.IsNotNull(capabilitiesArray);
                replacedert.IsTrue(capabilitiesArray.Count >= 0);
            }
        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstances4()
        {
            SimpleIoc.Default.Reset();

            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1());
            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1(), "key1");
            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1(), "key2");

            var instances = SimpleIoc.Default.GetAllInstances<ITestClreplaced>();
            replacedert.AreEqual(3, instances.Count());
        }

19 View Source File : Sessions.cs
License : MIT License
Project Creator : kfrajtak

[TestMethod]
        public void GetSessions_SingleEntry()
        {
            WindowsDriver<WindowsElement> session = Utility.CreateNewSession(CommonTestSettings.AlarmClockAppId);
            replacedert.IsNotNull(session);

            using (HttpWebResponse response = WebRequest.Create(CommonTestSettings.WindowsApplicationDriverUrl + "/sessions").GetResponse() as HttpWebResponse)
            {
                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                JObject responseObject = JObject.Parse(responseString);
                replacedert.AreEqual(0, (int)responseObject["status"]);

                JArray capabilitiesArray = (JArray)responseObject["value"];
                replacedert.IsTrue(capabilitiesArray.Count >= 1);

                // Verify that the newly created session is on the list
                JToken newSessionEntry = null;
                foreach (var entry in capabilitiesArray.Children())
                {
                    if (entry["id"].ToString() == session.SessionId.ToString())
                    {
                        newSessionEntry = entry;
                        break;
                    }
                }

                replacedert.IsNotNull(newSessionEntry);
                replacedert.AreEqual(CommonTestSettings.AlarmClockAppId, newSessionEntry["capabilities"]["app"].ToString());
            }

            session.Quit();
        }

19 View Source File : SearcherTest.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        public void CanSearchSeparateSites()
        {
            long siteId = 99;
            long siteId2 = 1;
			string culture = "en-US";

            // Setup Objects
			Lexicon l = new Lexicon(new StaticLexicon());
			Searcher s = new Searcher(l, new StaticSearcher());
			SimpleTextIndexer indexer = new SimpleTextIndexer(s);

			indexer.Index(siteId, "1", 0, "Doreplacedent Red", "Red is the first doreplacedent. Red is a test.", culture);
			indexer.Index(siteId, "2", 0, "Doreplacedent Blue", "Blue is the second doreplacedent not Red like the first. Blue doreplacedent is a sample", culture);
			indexer.Index(siteId, "3", 0, "Shakespeare: Julius Ceasar", "Et tu brute?", culture);
			indexer.Index(siteId2, "4", 0, "Shakespeare: To Be or Not To Be", "To be or not to be", culture);
			indexer.Index(siteId2, "5", 0, "Doc Brown", "The Flux Capacitor is what enables time travel. I fell off my toilet and hit my head. When I woke up, I drew this...", culture);

            string query = "Shakespeare";
            int total = 0;
            List<SearchObject> results = s.DoSearch(siteId, query, culture, 1, 10, ref total);
            replacedert.IsNotNull(results);
            replacedert.AreEqual(1, results.Count);
            replacedert.AreEqual("3", results[0].ObjectId);

            List<SearchObject> results2 = s.DoSearch(siteId2, query, culture, 1, 10, ref total);
            replacedert.IsNotNull(results2);
            replacedert.AreEqual(1, results2.Count);
            replacedert.AreEqual("4", results2[0].ObjectId);
        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstancesGeneric2()
        {
            SimpleIoc.Default.Reset();

            var instance = new TestClreplaced1();
            SimpleIoc.Default.Register(() => instance);

            var instances = SimpleIoc.Default.GetAllInstances<TestClreplaced1>();
            replacedert.AreEqual(1, instances.Count());

            SimpleIoc.Default.GetInstance<TestClreplaced1>("key1");

            instances = SimpleIoc.Default.GetAllInstances<TestClreplaced1>();
            replacedert.AreEqual(2, instances.Count());
        }

19 View Source File : SetupWizardTest3.cs
License : MIT License
Project Creator : HotcakesCommerce

public void DeleteShippingZone()
        {
            //Arrange
            var zone0 = _irepo.GetDeleteShippingZone();
            var zone1 = _application.OrderServices.ShippingZones.FindForStore(_application.CurrentStore.Id).FirstOrDefault(x => x.Name.Equals(zone0));
            if (zone1 == null) replacedert.AreEqual(0, 1);

            //Act/replacedert
            replacedert.IsTrue(_application.OrderServices.ShippingZones.Delete(zone1.Id));
        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstancesWithInterfaceGeneric()
        {
            const string key1 = "MyKey1";
            const string key2 = "MyKey2";
            const string key3 = "MyKey3";
            const string key4 = "MyKey4";

            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<ITestClreplaced, TestClreplaced1>();

            var instance1 = SimpleIoc.Default.GetInstance<ITestClreplaced>(key1);
            var instance2 = SimpleIoc.Default.GetInstance<ITestClreplaced>(key2);
            var instance3 = SimpleIoc.Default.GetInstance<ITestClreplaced>(key3);
            var instance4 = SimpleIoc.Default.GetInstance<ITestClreplaced>(key4);

            replacedert.IsNotNull(instance1);
            replacedert.IsNotNull(instance2);
            replacedert.IsNotNull(instance3);
            replacedert.IsNotNull(instance4);

            var createdInstances = SimpleIoc.Default.GetAllCreatedInstances<ITestClreplaced>();
            replacedert.AreEqual(4, createdInstances.Count());

            var allInstances = SimpleIoc.Default.GetAllInstances<ITestClreplaced>();
            replacedert.AreEqual(5, allInstances.Count()); // including default instance

            foreach (var instance in allInstances)
            {
                replacedert.IsNotNull(instance);

                if (instance.Equals(instance1))
                {
                    instance1 = null;
                }

                if (instance.Equals(instance2))
                {
                    instance2 = null;
                }

                if (instance.Equals(instance3))
                {
                    instance3 = null;
                }

                if (instance.Equals(instance4))
                {
                    instance4 = null;
                }
            }

            replacedert.IsNull(instance1);
            replacedert.IsNull(instance2);
            replacedert.IsNull(instance3);
            replacedert.IsNull(instance4);
        }

19 View Source File : SetupWizardTest3.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        [Priority(30)]
        public void UPS_DomesticTestRate()
        {
            #region Arrange
            var shipment = _irepo.GetTestRate_UPS_DomesticShipment();
            var item = _irepo.GetTestRate_UPS_DomesticShippableInfo();
            shipment.Items.Add(item);
            var globalSettings = new USPostalServiceGlobalSettings {
				UserId = _application.CurrentStore.Settings.ShippingUSPostalUserId,
				DiagnosticsMode = true,
				IgnoreDimensions = false
			};
            var settings = _irepo.GetTestRate_UPS_DomesticServiceSetting();

            var servicecodes = AvailableServices.FindById(GetShippingProviderId("US Postal Service - Domestic"), _application.CurrentStore).ListAllServiceCodes();

            var displayname = settings.ServiceCodeFilter.FirstOrDefault().DisplayName;

            var code = servicecodes.FirstOrDefault(x => x.DisplayName.Equals(displayname));

            settings.ServiceCodeFilter = new List<IServiceCode> { code };

            var provider = new DomesticProvider(globalSettings, new Web.Logging.TextLogger())
                {
                    Settings = settings
                };
            #endregion

            //Act
            var rates = provider.RateShipment(shipment);

            //replacedert
            if (rates == null)
                replacedert.AreEqual(1, 0);
            else
                replacedert.AreEqual(25, rates.FirstOrDefault().EstimatedCost);

        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstances2()
        {
            SimpleIoc.Default.Reset();

            var instance = new TestClreplaced1();
            SimpleIoc.Default.Register(() => instance);

            var instances = SimpleIoc.Default.GetAllInstances<TestClreplaced1>();
            replacedert.AreEqual(1, instances.Count());

            SimpleIoc.Default.GetInstance<TestClreplaced1>("key1");

            instances = SimpleIoc.Default.GetAllInstances<TestClreplaced1>();
            replacedert.AreEqual(2, instances.Count());
        }

19 View Source File : RelayCommandTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestCallingExecuteWhenCanExecuteIsFalse()
        {
            var counter = 0;

            var command = new RelayCommand(
                () => counter++,
                () => _canExecute);

            command.Execute(null);
            replacedert.AreEqual(1, counter);
            _canExecute = false;
            command.Execute(null);
            replacedert.AreEqual(1, counter);
            _canExecute = true;
            command.Execute(null);
            replacedert.AreEqual(2, counter);
        }

19 View Source File : AffiliateTest.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        public void Affiliate_CanAddAffiliateWithExistedUser()
        {
            using (ShimsContext.Create())
            {
                InitShims();
                var users = new List<UserInfo>();
                var dnnUserCtl = GetStubIUserController(users);
                DnnGlobal.SetTestableInstance(GetStubIDnnGlobal());
                DnnUserController.SetTestableInstance(dnnUserCtl);
                users.Add(dnnUserCtl.BuildUserInfo(
                    "user1", "User", "First", "[email protected]",
                    "12345", DnnGlobal.Instance.GetPortalId()));

                var hccApp = CreateHccAppInMemory();
                var target = hccApp.ContactServices.Affiliates;

                var expected = new Affiliate
                {
                    AffiliateId = "001",
                    UserId = users[0].UserID,
                    TaxId = "123",
                    Username = "Username"
                };

                var status = CreateUserStatus.None;
                var res = target.Create(expected, ref status);
                var actual = target.FindAllPaged(1, 1).First();

                replacedert.AreEqual(1, target.CountOfAll());
                replacedert.AreEqual(expected.TaxId, actual.TaxId);
                replacedert.AreEqual(expected.Username, actual.Username);
                replacedert.AreEqual(1, users.Count);
            }
        }

19 View Source File : RelayCommandTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestCanExecuteChanged()
        {
            var command = new RelayCommand(
                () =>
                {
                },
                () => true);

            var canExecuteChangedCalled = 0;

            var canExecuteChangedEventHandler = new EventHandler((s, e) => canExecuteChangedCalled++);

            command.CanExecuteChanged += canExecuteChangedEventHandler;

            command.RaiseCanExecuteChanged();

#if SILVERLIGHT
             replacedert.AreEqual(1, canExecuteChangedCalled);
#elif NETFX_CORE
            replacedert.AreEqual(1, canExecuteChangedCalled);
#elif PORTABLE
            replacedert.AreEqual(1, canExecuteChangedCalled);
#else
            // In WPF, cannot trigger the CanExecuteChanged event like this
            replacedert.AreEqual(0, canExecuteChangedCalled);
#endif

            command.CanExecuteChanged -= canExecuteChangedEventHandler;
            command.RaiseCanExecuteChanged();

#if SILVERLIGHT
             replacedert.AreEqual(1, canExecuteChangedCalled);
#elif NETFX_CORE
            replacedert.AreEqual(1, canExecuteChangedCalled);
#elif PORTABLE
            replacedert.AreEqual(1, canExecuteChangedCalled);
#else
            // In WPF, cannot trigger the CanExecuteChanged event like this
            replacedert.AreEqual(0, canExecuteChangedCalled);
#endif
        }

19 View Source File : SetupWizardTest3.cs
License : MIT License
Project Creator : HotcakesCommerce

public void DeleteZoneArea()
        {
            #region Arrange
            var zone0 = _irepo.GetDeleteZoneArea();
            var zone1 = _application.OrderServices.ShippingZones.FindForStore(_application.CurrentStore.Id).FirstOrDefault(x => x.Name.Equals(zone0.Name));
            if (zone1 == null) replacedert.AreEqual(0, 1);

            var removezone = _application.OrderServices.ShippingZones.FindForStore(_application.CurrentStore.Id)
                             .FirstOrDefault(x => x.Name.Equals(zone0.Name));
            var removezonearea = removezone.Areas.FirstOrDefault(x => x.CountryIsoAlpha3.Equals(zone0.Areas.FirstOrDefault().CountryIsoAlpha3));

            #endregion
            #region Act
            _application.OrderServices.ShippingZoneRemoveArea(removezone.Id, removezonearea.CountryIsoAlpha3,
                                                                removezonearea.RegionAbbreviation);


            var resultarea = _application.OrderServices.ShippingZones.FindForStore(_application.CurrentStore.Id)
                             .FirstOrDefault(x => x.Name.Equals(zone0.Name)).Areas.FirstOrDefault(x => x.CountryIsoAlpha3.Equals(zone0.Areas.FirstOrDefault().CountryIsoAlpha3));

            #endregion

            //replacedert
            replacedert.IsTrue(resultarea == null);

        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetEmptyInstances()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<TestClreplaced1>();

            const string key1 = "My key 1";
            const string key2 = "My key 2";

            SimpleIoc.Default.GetInstance<TestClreplaced1>(key1);
            SimpleIoc.Default.GetInstance<TestClreplaced1>(key2);

            var allInstances = SimpleIoc.Default.GetAllInstances(typeof (TestClreplaced2));

            replacedert.IsNotNull(allInstances);
            replacedert.AreEqual(0, allInstances.Count());
        }

19 View Source File : QueryParserTest.cs
License : MIT License
Project Creator : HotcakesCommerce

private void replacedertListsAreEqual(List<string> expected, List<string> actual)
        {
            replacedert.IsNotNull(actual);
            replacedert.AreEqual(expected.Count, actual.Count);
            for (var i = 0; i < expected.Count; i++)
            {
                replacedert.AreEqual(expected[i], actual[i], "Word didn't match: " + actual[i] + " expected " + expected[i]);
            }
        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstancesGeneric4()
        {
            SimpleIoc.Default.Reset();

            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1());
            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1(), "key1");
            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1(), "key2");

            var instances = SimpleIoc.Default.GetAllInstances<ITestClreplaced>();
            replacedert.AreEqual(3, instances.Count());
        }

19 View Source File : SearcherTest.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        public void CanFindObjectsForWord()
        {
            long siteId = 0;
			string culture = "en-US";

            // Setup Words
			Lexicon lexicon = new Lexicon(new StaticLexicon());
			long thi_id = lexicon.AddOrCreateWord("thi", culture);
			long test_id = lexicon.AddOrCreateWord("test", culture);
			long sampl_id = lexicon.AddOrCreateWord("sampl", culture);

            // Setup Search Objects
			SearchObject s1 = new SearchObject();
            s1.ObjectType = 0;
            s1.ObjectId = "1";
			SearchObject s2 = new SearchObject();
            s2.ObjectType = 0;
            s2.ObjectId = "2";

            // Setup Searcher
			Searcher searcher = new Searcher(lexicon, new StaticSearcher());

            // Record Objects
            long sid1 = searcher.ObjectIndexAddOrUpdate(s1);
            long sid2 = searcher.ObjectIndexAddOrUpdate(s2);

            // Index Words for Objects
			SearchObjectWord w1_1 = new SearchObjectWord() { SearchObjectId = s1.Id, WordId = thi_id, Score = 1, SiteId = siteId };
			SearchObjectWord w1_2 = new SearchObjectWord() { SearchObjectId = s1.Id, WordId = test_id, Score = 1, SiteId = siteId };
			SearchObjectWord w2_1 = new SearchObjectWord() { SearchObjectId = s2.Id, WordId = thi_id, Score = 1, SiteId = siteId };
			SearchObjectWord w2_2 = new SearchObjectWord() { SearchObjectId = s2.Id, WordId = sampl_id, Score = 1, SiteId = siteId };
            searcher.ObjectWordIndexUpdate(w1_1);
            searcher.ObjectWordIndexUpdate(w1_2);
            searcher.ObjectWordIndexUpdate(w2_1);
            searcher.ObjectWordIndexUpdate(w2_2);

            // Test
            List<SearchObjectWord> actual = searcher.ObjectWordIndexFindByWordId(siteId, thi_id);
            replacedert.IsNotNull(actual);
            replacedert.AreEqual(2, actual.Count);

            List<SearchObjectWord> actual2 = searcher.ObjectWordIndexFindByWordId(siteId, test_id);
            replacedert.IsNotNull(actual2);
            replacedert.AreEqual(1, actual2.Count);

            List<SearchObjectWord> actual3 = searcher.ObjectWordIndexFindByWordId(siteId, 99);
            replacedert.IsNotNull(actual3);
            replacedert.AreEqual(0, actual3.Count);
        }

19 View Source File : SimpleIocTestCreationTime.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestCreationOfMultipleInstances()
        {
            SimpleIoc.Default.Reset();
            TestClreplacedForCreationTime.Reset();

            var factoryWasUsed = 0;

            SimpleIoc.Default.Register(
                () =>
                {
                    factoryWasUsed++;
                    return new TestClreplacedForCreationTime();
                });

            replacedert.AreEqual(0, TestClreplacedForCreationTime.InstancesCreated);

            SimpleIoc.Default.GetInstance<TestClreplacedForCreationTime>();
            SimpleIoc.Default.GetInstance<TestClreplacedForCreationTime>("Key1");
            SimpleIoc.Default.GetInstance<TestClreplacedForCreationTime>("Key2");

            replacedert.AreEqual(3, TestClreplacedForCreationTime.InstancesCreated);
            replacedert.AreEqual(3, factoryWasUsed);
        }

19 View Source File : ProgressBar.cs
License : MIT License
Project Creator : kfrajtak

[TestMethod]
        public void Text()
        {
            var originalValue = int.Parse(progressBarElement.Text);
            replacedert.IsTrue(originalValue >= 0);
            clickAndHoldButton.Click();
            replacedert.AreEqual(originalValue + 1, int.Parse(progressBarElement.Text));
            clickAndHoldButton.Click();
            replacedert.AreEqual(originalValue + 2, int.Parse(progressBarElement.Text));
        }

19 View Source File : Slider.cs
License : MIT License
Project Creator : kfrajtak

[TestMethod]
        public void Text()
        {
            sliderElement1.Click();
            replacedert.IsTrue(int.Parse(sliderElement1.Text) > 45); // The value of the slider when the center is clicked should be greater than 45 and close to 50

            sliderElement2.Click();
            replacedert.AreEqual(750, int.Parse(sliderElement2.Text)); // The value of the slider when the center is clicked should be 750
        }

19 View Source File : SearcherTest.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        public void CanDoTwoWordSearch()
        {
            long siteId = 0;
			string culture = "en-US";

            // Setup Objects
			Lexicon l = new Lexicon(new StaticLexicon());
			Searcher s = new Searcher(l, new StaticSearcher());
			SimpleTextIndexer indexer = new SimpleTextIndexer(s);

			indexer.Index(siteId, "1", 0, "Doreplacedent Red", "Red is the first doreplacedent. Red is a test.", culture);
			indexer.Index(siteId, "2", 0, "Doreplacedent Blue", "Blue is the second doreplacedent not Red like the first. Blue Blue doreplacedent is a sample", culture);
			indexer.Index(siteId, "3", 0, "Shakespeare: Julius Ceasar", "Et tu brute?", culture);
			indexer.Index(siteId, "4", 0, "Shakespeare: To Be or Not To Be", "To be or not to be Red Red Red Red Red Red Red", culture);
			indexer.Index(siteId, "5", 0, "Doc Brown", "The Flux Capacitor is what enables time travel. I fell off my toilet and hit my head. When I woke up, I drew this...", culture);

            string query = "doreplacedent blue";
            int total = 0;
			List<SearchObject> results = s.DoSearch(query, 1, 10, culture, ref total);
            replacedert.IsNotNull(results);
            replacedert.AreEqual(1, results.Count);
        }

19 View Source File : RelayCommandGenericTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestCanExecuteChanged()
        {
            var command = new RelayCommand<string>(
                p =>
                {
                },
                p => true);

            var canExecuteChangedCalled = 0;

            var canExecuteChangedEventHandler = new EventHandler((s, e) => canExecuteChangedCalled++);

            command.CanExecuteChanged += canExecuteChangedEventHandler;

            command.RaiseCanExecuteChanged();

#if SILVERLIGHT
             replacedert.AreEqual(1, canExecuteChangedCalled);
#elif NETFX_CORE
            replacedert.AreEqual(1, canExecuteChangedCalled);
#elif PORTABLE
            replacedert.AreEqual(1, canExecuteChangedCalled);
#else
            // In WPF, cannot trigger the CanExecuteChanged event like this
            replacedert.AreEqual(0, canExecuteChangedCalled);
#endif

            command.CanExecuteChanged -= canExecuteChangedEventHandler;

            command.RaiseCanExecuteChanged();

#if SILVERLIGHT
             replacedert.AreEqual(1, canExecuteChangedCalled);
#elif NETFX_CORE
            replacedert.AreEqual(1, canExecuteChangedCalled);
#elif PORTABLE
            replacedert.AreEqual(1, canExecuteChangedCalled);
#else
            // In WPF, cannot trigger the CanExecuteChanged event like this
            replacedert.AreEqual(0, canExecuteChangedCalled);
#endif
        }

19 View Source File : SetupWizardTest3.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        [Priority(31)]
        public void UPS_InternationalTestRate()
        {
            #region Arrange
            var shipment = _irepo.GetTestRate_UPS_InternationShipment();
            var item = _irepo.GetTestRate_UPS_InternationShippableInfo();
            var settings = _irepo.GetTestRate_UPS_InternationServiceSetting();
            shipment.Items.Add(item);
            var globalSettings = new USPostalServiceGlobalSettings { DiagnosticsMode = true, IgnoreDimensions = false };

            var servicecodes = AvailableServices.FindById(GetShippingProviderId("US Postal Service - International"), _application.CurrentStore).ListAllServiceCodes();
            var displayname = settings.ServiceCodeFilter.FirstOrDefault().DisplayName;
            var code = servicecodes.FirstOrDefault(x => x.DisplayName.Equals(displayname));
            settings.ServiceCodeFilter = new List<IServiceCode> { code };

            var provider = new InternationalProvider(globalSettings, new Web.Logging.TextLogger())
                {
                    Settings = settings
                };
            #endregion

            //Act
            var rates = provider.RateShipment(shipment);

            //replacedert
            if (rates == null)
                replacedert.AreEqual(1, 0);
            else
                replacedert.AreEqual(25, rates.FirstOrDefault().EstimatedCost);

        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstancesWithTypeGeneric()
        {
            const string key1 = "MyKey1";
            const string key2 = "MyKey2";
            const string key3 = "MyKey3";
            const string key4 = "MyKey4";
            const string key5 = "MyKey5";
            const string key6 = "MyKey6";

            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<TestClreplaced1>();
            SimpleIoc.Default.Register<TestClreplaced2>();

            var instance1 = SimpleIoc.Default.GetInstance<TestClreplaced1>(key1);
            var instance2 = SimpleIoc.Default.GetInstance<TestClreplaced1>(key2);
            var instance3 = SimpleIoc.Default.GetInstance<TestClreplaced1>(key3);
            var instance4 = SimpleIoc.Default.GetInstance<TestClreplaced1>(key4);
            var instance5 = SimpleIoc.Default.GetInstance<TestClreplaced2>(key5);
            var instance6 = SimpleIoc.Default.GetInstance<TestClreplaced2>(key6);

            replacedert.IsNotNull(instance1);
            replacedert.IsNotNull(instance2);
            replacedert.IsNotNull(instance3);
            replacedert.IsNotNull(instance4);
            replacedert.IsNotNull(instance5);
            replacedert.IsNotNull(instance6);

            var createdInstances = SimpleIoc.Default.GetAllCreatedInstances<TestClreplaced1>();
            replacedert.AreEqual(4, createdInstances.Count());

            var allInstances = SimpleIoc.Default.GetAllInstances<TestClreplaced1>();
            replacedert.AreEqual(5, allInstances.Count()); // including default instance

            foreach (var instance in allInstances)
            {
                replacedert.IsNotNull(instance);

                if (instance.Equals(instance1))
                {
                    instance1 = null;
                }

                if (instance.Equals(instance2))
                {
                    instance2 = null;
                }

                if (instance.Equals(instance3))
                {
                    instance3 = null;
                }

                if (instance.Equals(instance4))
                {
                    instance4 = null;
                }

                if (instance.Equals(instance5))
                {
                    instance5 = null;
                }

                if (instance.Equals(instance6))
                {
                    instance6 = null;
                }
            }

            replacedert.IsNull(instance1);
            replacedert.IsNull(instance2);
            replacedert.IsNull(instance3);
            replacedert.IsNull(instance4);
            replacedert.IsNotNull(instance5);
            replacedert.IsNotNull(instance6);
        }

19 View Source File : SimpleIocTestAutoCreation.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestAutoCreationWithInterface()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<ITestClreplaced, TestClreplaced1>(true);

            var instances = SimpleIoc.Default.GetAllInstances<ITestClreplaced>();
            replacedert.AreEqual(1, instances.Count());

            var defaultInstance = SimpleIoc.Default.GetInstance<ITestClreplaced>();
            replacedert.AreSame(defaultInstance, instances.ElementAt(0));
        }

19 View Source File : SetupWizardTest3.cs
License : MIT License
Project Creator : HotcakesCommerce

public void CreateShippingZone()
        {
            //Arrange
            var store = _application.CurrentStore;
            var zonename = _irepo.GetAddShippingZoneName();
            var z = new Zone { Name = zonename, StoreId = store.Id };

            //Act
            _application.OrderServices.ShippingZones.Create(z);
            var firstOrDefault = _application.OrderServices.ShippingZones.GetZones(store.Id).FirstOrDefault(x => x.Name.Equals(zonename));
            if (firstOrDefault == null) replacedert.AreEqual(0, 1);
            var result = firstOrDefault.Name;

            //replacedert
            replacedert.AreEqual(zonename, result);
        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstances3()
        {
            SimpleIoc.Default.Reset();

            SimpleIoc.Default.Register<ITestClreplaced, TestClreplaced1>();
            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1(), "key1");
            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1(), "key2");

            var instances = SimpleIoc.Default.GetAllInstances<ITestClreplaced>();
            replacedert.AreEqual(3, instances.Count());
        }

19 View Source File : SetupWizardTest3.cs
License : MIT License
Project Creator : HotcakesCommerce

public void AddZoneArea()
        {
            #region Arrange
            var zone0 = _irepo.GetAddZoneArea();
            var zone1 = _application.OrderServices.ShippingZones.FindForStore(_application.CurrentStore.Id).FirstOrDefault(x => x.Name.Equals(zone0.Name));
            if (zone1 == null) replacedert.AreEqual(0, 1);

            var area = new ZoneArea
             {
                 CountryIsoAlpha3 = zone0.Areas.FirstOrDefault().CountryIsoAlpha3,
                 RegionAbbreviation = zone0.Areas.FirstOrDefault().RegionAbbreviation,
             };
            zone1.Areas.Add(area);
            #endregion

            #region Act
            _application.OrderServices.ShippingZones.Update(zone1);

            var resultzonearea = _application.OrderServices.ShippingZones.FindForStore(_application.CurrentStore.Id)
                                .FirstOrDefault(x => x.Name.Equals(zone0.Name))
                                .Areas.FirstOrDefault(x => x.CountryIsoAlpha3.Equals(zone0.Areas.FirstOrDefault().CountryIsoAlpha3));

            #endregion

            //replacedert
            replacedert.AreEqual(zone0.Areas.FirstOrDefault().CountryIsoAlpha3, resultzonearea.CountryIsoAlpha3);
            replacedert.AreEqual(zone0.Areas.FirstOrDefault().RegionAbbreviation, resultzonearea.RegionAbbreviation);

        }

19 View Source File : RelayCommandGenericTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestValueTypeConversion()
        {
            Reset();

            const int inputInt = 1234;
            const double inputDouble = 1234.5678;
            const bool inputBool = true;

            var resultInt = 0;
            var resultBool = false;
            var resultDouble = 0.0;

            var commandInt = new RelayCommand<int>(
                p =>
                {
                    resultInt = p;
                },
                p => true);

            var commandBool = new RelayCommand<bool>(
                p =>
                {
                    resultBool = p;
                },
                p => true);

            var commandDouble = new RelayCommand<double>(
                p =>
                {
                    resultDouble = p;
                },
                p => true);

            replacedert.AreEqual(0, resultInt);
            replacedert.AreEqual(false, resultBool);
            replacedert.AreEqual(0.0, resultDouble);
            commandInt.Execute(inputInt.ToString());
            commandBool.Execute(inputBool.ToString());
            commandDouble.Execute(inputDouble.ToString());
            replacedert.AreEqual(inputInt, resultInt);
            replacedert.AreEqual(inputBool, resultBool);
            replacedert.AreEqual(inputDouble, resultDouble);
        }

19 View Source File : SearcherTest.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        public void CanDoOneWordSearch()
        {
            long siteId = 0;
			string culture = "en-US";

            // Setup Objects
			Lexicon l = new Lexicon(new StaticLexicon());
			Searcher s = new Searcher(l, new StaticSearcher());
			SimpleTextIndexer indexer = new SimpleTextIndexer(s);

			indexer.Index(siteId, "1", 0, "Doreplacedent Red", "Red is the first doreplacedent. Red is a test.", culture);
			indexer.Index(siteId, "2", 0, "Doreplacedent Blue", "Blue is the second doreplacedent not Red like the first. Blue doreplacedent is a sample", culture);
			indexer.Index(siteId, "3", 0, "Shakespeare: Julius Ceasar", "Et tu brute?", culture);
			indexer.Index(siteId, "4", 0, "Shakespeare: To Be or Not To Be", "To be or not to be", culture);
			indexer.Index(siteId, "5", 0, "Doc Brown", "The Flux Capacitor is what enables time travel. I fell off my toilet and hit my head. When I woke up, I drew this...", culture);

            string query = "doreplacedent";
            
            int total = 0;
			List<SearchObject> results = s.DoSearch(query, 1, 10, culture, ref total);
            replacedert.IsNotNull(results);
            replacedert.AreEqual(2, results.Count);
        }

19 View Source File : SimpleIocTestAutoCreation.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestAutoCreationWithFactoryAndKey()
        {
            SimpleIoc.Default.Reset();
            const string key1 = "key1";
            SimpleIoc.Default.Register(
                () => new TestClreplaced1(),
                key1,
                true);

            var instances = SimpleIoc.Default.GetAllInstances<TestClreplaced1>();
            replacedert.AreEqual(1, instances.Count());

            var defaultInstance = SimpleIoc.Default.GetInstance<TestClreplaced1>(key1);
            replacedert.AreSame(defaultInstance, instances.ElementAt(0));
        }

19 View Source File : CatalogServiceTest.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        public void CatalogService_VariantsValidate()
        {
            // This unit test should test following result:
            // 1. INVALID variants were removed
            // 2. SHORT variants were updated
            // 3. INVENTORY were regenerated

            var app = CreateHccAppInMemory();

            // 0. Prepare products with 2 choices and 6 variants
            var p = new Product
            {
                Sku = "S001",
                ProductName = "Sample Product1"
            };

            app.CatalogServices.ProductsCreateWithInventory(p);

            var oSize = Option.Factory(OptionTypes.DropDownList);
            oSize.Name = "Size";
            oSize.IsVariant = true;
            oSize.AddItem("Small");
            oSize.AddItem("Medium");
            oSize.AddItem("Large");

            var oColor = Option.Factory(OptionTypes.RadioButtonList);
            oColor.Name = "Color";
            oColor.IsVariant = true;
            oColor.AddItem("Black");
            oColor.AddItem("Red");

            p.Options.Add(oSize);
            p.Options.Add(oColor);
            app.CatalogServices.Products.Update(p);

            var variants = app.CatalogServices.ProductVariants.FindByProductId(p.Bvin);
            var actualInventories = app.CatalogServices.ProductInventories.FindByProductId(p.Bvin);
            replacedert.AreEqual(0, variants.Count);
            replacedert.AreEqual(1, actualInventories.Count);

            // Variants generating
            var possibleCount = 0;
            app.CatalogServices.VariantsGenerateAllPossible(p, out possibleCount);
            replacedert.AreEqual(6, possibleCount);

            // RELOAD product (current p.Variants doesn contain any items!!!)
            p = app.CatalogServices.Products.Find(p.Bvin);
            variants = app.CatalogServices.ProductVariants.FindByProductId(p.Bvin);
            actualInventories = app.CatalogServices.ProductInventories.FindByProductId(p.Bvin);
            replacedert.AreEqual(6, variants.Count);
            //replacedert.AreEqual(6, actualInventories.Count); 
            replacedert.AreEqual(1, actualInventories.Count); // !!! INVENTORY DOESNOT REGENERATE AUTOMATIC

            oSize = p.Options.FirstOrDefault(o => o.Name == "Size");
            replacedert.IsNotNull(oSize);

            oSize.Items.RemoveAt(2); // Remove "Large" size item

            var oType = Option.Factory(OptionTypes.DropDownList);
            oType.Name = "Type";
            oType.IsVariant = true;
            oType.AddItem("Basic");
            oType.AddItem("Pro");
            p.Options.Add(oType); // Add new VARIANT option
            app.CatalogServices.Products.Update(p);

            // ===================== BEFORE Validate Variants =====================
            variants = app.CatalogServices.ProductVariants.FindByProductId(p.Bvin);
            actualInventories = app.CatalogServices.ProductInventories.FindByProductId(p.Bvin);
            replacedert.AreEqual(6, variants.Count);
            replacedert.AreEqual(1, actualInventories.Count);
            replacedert.AreEqual(2, variants[0].Selections.Count);


            // ===================== AFTER Validate Variants =====================
            app.CatalogServices.VariantsValidate(p);

            variants = app.CatalogServices.ProductVariants.FindByProductId(p.Bvin);
            actualInventories = app.CatalogServices.ProductInventories.FindByProductId(p.Bvin);
            replacedert.AreEqual(4, variants.Count);
            replacedert.AreEqual(4, actualInventories.Count);
            replacedert.AreEqual(3, variants[0].Selections.Count);
        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstancesWithInterface()
        {
            const string key1 = "MyKey1";
            const string key2 = "MyKey2";
            const string key3 = "MyKey3";
            const string key4 = "MyKey4";

            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<ITestClreplaced, TestClreplaced1>();

            var instance1 = SimpleIoc.Default.GetInstance(typeof (ITestClreplaced), key1);
            var instance2 = SimpleIoc.Default.GetInstance(typeof (ITestClreplaced), key2);
            var instance3 = SimpleIoc.Default.GetInstance(typeof (ITestClreplaced), key3);
            var instance4 = SimpleIoc.Default.GetInstance(typeof (ITestClreplaced), key4);

            replacedert.IsNotNull(instance1);
            replacedert.IsNotNull(instance2);
            replacedert.IsNotNull(instance3);
            replacedert.IsNotNull(instance4);

            var createdInstances = SimpleIoc.Default.GetAllCreatedInstances<ITestClreplaced>();
            replacedert.AreEqual(4, createdInstances.Count());

            var allInstances = SimpleIoc.Default.GetAllInstances(typeof (ITestClreplaced));
            replacedert.AreEqual(5, allInstances.Count());

            foreach (var instance in allInstances)
            {
                replacedert.IsNotNull(instance);

                if (instance.Equals(instance1))
                {
                    instance1 = null;
                }

                if (instance.Equals(instance2))
                {
                    instance2 = null;
                }

                if (instance.Equals(instance3))
                {
                    instance3 = null;
                }

                if (instance.Equals(instance4))
                {
                    instance4 = null;
                }
            }

            replacedert.IsNull(instance1);
            replacedert.IsNull(instance2);
            replacedert.IsNull(instance3);
            replacedert.IsNull(instance4);
        }

19 View Source File : SimpleTextIndexer.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        public void CanIndexAnObject()
        {
			string culture = "en-US";
            string message = "Red is a sample or red is a test.";

			Lexicon l = new Lexicon(new StaticLexicon());
			Searcher s = new Searcher(l, new StaticSearcher());

			SimpleTextIndexer indexer = new SimpleTextIndexer(s);

			indexer.Index(0, "1234", 0, "", message, culture);

            SearchObject actual = s.ObjectIndexFindByTypeAndId(0, 0, "1234");
            replacedert.IsNotNull(actual);

            List<SearchObjectWord> words = s.ObjectWordIndexFindAll();
            replacedert.IsNotNull(words);

            List<SearchObjectWord> expected = new List<SearchObjectWord>();
			expected.Add(new SearchObjectWord() { SearchObjectId = actual.Id, WordId = l.FindWordId("red", culture), Score = 2 });
			expected.Add(new SearchObjectWord() { SearchObjectId = actual.Id, WordId = l.FindWordId("sampl", culture), Score = 1 });
			expected.Add(new SearchObjectWord() { SearchObjectId = actual.Id, WordId = l.FindWordId("test", culture), Score = 1 });

            replacedert.AreEqual(expected.Count, words.Count);
            replacedert.AreEqual(expected[0].WordId, words[0].WordId);
            replacedert.AreEqual(expected[1].WordId, words[1].WordId);
            replacedert.AreEqual(expected[2].WordId, words[2].WordId);
            replacedert.AreEqual(expected[0].Score, words[0].Score);
            replacedert.AreEqual(expected[1].Score, words[1].Score);
            replacedert.AreEqual(expected[2].Score, words[2].Score);

        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetEmptyInstancesGeneric()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<TestClreplaced1>();

            const string key1 = "My key 1";
            const string key2 = "My key 2";

            SimpleIoc.Default.GetInstance<TestClreplaced1>(key1);
            SimpleIoc.Default.GetInstance<TestClreplaced1>(key2);

            var allInstances = SimpleIoc.Default.GetAllInstances<TestClreplaced2>();

            replacedert.IsNotNull(allInstances);
            replacedert.AreEqual(0, allInstances.Count());
        }

19 View Source File : SetupWizardTest3.cs
License : MIT License
Project Creator : HotcakesCommerce

public void EditShippingZone()
        {
            //Arrange
            var zone0 = _irepo.GetEditShippingZone();
            var zone1 = _application.OrderServices.ShippingZones.FindForStore(_application.CurrentStore.Id).FirstOrDefault(x => x.Name.Equals(Convert.ToString(zone0["OldName"])));
            if (zone1 == null) replacedert.AreEqual(0, 1);
            zone1.Name = Convert.ToString(zone0["NewName"]);

            //Act/replacedert
            replacedert.IsTrue(_application.OrderServices.ShippingZones.Update(zone1));
        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstancesGeneric3()
        {
            SimpleIoc.Default.Reset();

            SimpleIoc.Default.Register<ITestClreplaced, TestClreplaced1>();
            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1(), "key1");
            SimpleIoc.Default.Register<ITestClreplaced>(() => new TestClreplaced1(), "key2");

            var instances = SimpleIoc.Default.GetAllInstances<ITestClreplaced>();
            replacedert.AreEqual(3, instances.Count());
        }

19 View Source File : Screenshot.cs
License : MIT License
Project Creator : kfrajtak

[TestMethod]
        public void GetElementScreenshot()
        {
            WindowsDriver<WindowsElement> desktopSession = null;

            try
            {
                // Locate the AlarmPivoreplacedem element in Alarms & Clock app to be captured
                WindowsElement alarmPivoreplacedem1 = session.FindElementByAccessibilityId(AlarmTabAutomationId);
                OpenQA.Selenium.Screenshot alarmPivoreplacedemScreenshot1 = alarmPivoreplacedem1.GetScreenshot();               

                // Save the AlarmPivoreplacedem screenshot capture locally on the machine running the test
                alarmPivoreplacedemScreenshot1.SaveAsFile(@"ScreenshotAlarmPivoreplacedem.png", ScreenshotImageFormat.Png);

                // Using the Desktop session, locate the same AlarmPivoreplacedem element in Alarms & Clock app to be captured
                desktopSession = Utility.CreateNewSession(CommonTestSettings.DesktopAppId);
                WindowsElement alarmPivoreplacedem2 = desktopSession.FindElementByAccessibilityId(AlarmTabAutomationId);
                OpenQA.Selenium.Screenshot alarmPivoreplacedemScreenshot2 = alarmPivoreplacedem2.GetScreenshot();

                // Using the Desktop session, locate the Alarms & Clock app top level window to be captured
                WindowsElement alarmsClockWindowTopWindow = desktopSession.FindElementByName("Alarms & Clock");
                OpenQA.Selenium.Screenshot alarmsClockWindowTopWindowScreenshot = alarmsClockWindowTopWindow.GetScreenshot();

                using (MemoryStream msScreenshot1 = new MemoryStream(alarmPivoreplacedemScreenshot1.AsByteArray))
                using (MemoryStream msScreenshot2 = new MemoryStream(alarmPivoreplacedemScreenshot2.AsByteArray))
                using (MemoryStream msScreenshot3 = new MemoryStream(alarmsClockWindowTopWindowScreenshot.AsByteArray))
                {
                    // Verify that the element screenshot has a valid size
                    Image screenshotImage1 = Image.FromStream(msScreenshot1);
                    replacedert.AreEqual(alarmPivoreplacedem1.Size.Height, screenshotImage1.Height);
                    replacedert.AreEqual(alarmPivoreplacedem1.Size.Width, screenshotImage1.Width);

                    // Verify that the element screenshot captured using the Alarms & Clock session
                    // is identical in size with the one taken using the desktop session
                    Image screenshotImage2 = Image.FromStream(msScreenshot2);
                    replacedert.AreEqual(screenshotImage1.Height, screenshotImage2.Height);
                    replacedert.AreEqual(screenshotImage1.Width, screenshotImage2.Width);

                    // Verify that the element screenshot is smaller in size compared to the application top level window
                    Image screenshotImage3 = Image.FromStream(msScreenshot3);
                    replacedert.AreEqual(alarmsClockWindowTopWindow.Size.Height, screenshotImage3.Height);
                    replacedert.AreEqual(alarmsClockWindowTopWindow.Size.Width, screenshotImage3.Width);
                    replacedert.IsTrue(screenshotImage3.Height > screenshotImage1.Height);
                    replacedert.IsTrue(screenshotImage3.Width > screenshotImage1.Width);
                }
            }
            finally
            {
                if (desktopSession != null)
                {
                    desktopSession.Quit();
                }
            }
        }

19 View Source File : MessengerRegisterUnregisterTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestRegisterStrictAndNonStrictRecipients()
        {
            var testContentDateTime = DateTime.Now;
            const string testContentString = "abcd";

            Messenger.Reset();
            Reset();

            var receivedMessages = 0;

            Messenger.Default.Register<TestMessageGenericBase>(
                this,
                true,
                m =>
                {
                    receivedMessages++;

                    var dateTimeMessage =
                        m as TestMessageGeneric<DateTime>;
                    if (dateTimeMessage != null)
                    {
                        ReceivedContentDateTime1 =
                            dateTimeMessage.Content;
                        return;
                    }

                    var stringMessage = m as TestMessageGeneric<string>;
                    if (stringMessage != null)
                    {
                        ReceivedContentStringA1 = stringMessage.Content;
                        return;
                    }
                });

            Messenger.Default.Register<TestMessageGeneric<DateTime>>(this,
                                                                     m =>
                                                                     {
                                                                         receivedMessages++;
                                                                         ReceivedContentDateTime2 = m.Content;
                                                                     });

            replacedert.AreEqual(null, ReceivedContentStringA1);
            replacedert.AreEqual(DateTime.MinValue, ReceivedContentDateTime1);
            replacedert.AreEqual(DateTime.MinValue, ReceivedContentDateTime2);

            Messenger.Default.Send(new TestMessageGeneric<DateTime>
            {
                Content = testContentDateTime
            });

            replacedert.AreEqual(2, receivedMessages);
            replacedert.AreEqual(null, ReceivedContentStringA1);
            replacedert.AreEqual(testContentDateTime, ReceivedContentDateTime1);
            replacedert.AreEqual(testContentDateTime, ReceivedContentDateTime2);

            Messenger.Default.Send(new TestMessageGeneric<string>
            {
                Content = testContentString
            });

            replacedert.AreEqual(3, receivedMessages);
            replacedert.AreEqual(testContentString, ReceivedContentStringA1);
            replacedert.AreEqual(testContentDateTime, ReceivedContentDateTime1);
            replacedert.AreEqual(testContentDateTime, ReceivedContentDateTime2);
        }

19 View Source File : TestUtility.cs
License : Apache License 2.0
Project Creator : CoatiSoftware

public static void CloseCurrentSolution()
		{
			IVsSolution solutionService = (IVsSolution)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution));
			int ret = solutionService.CloseSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_NoSave, null, 0);
			replacedert.AreEqual(VSConstants.S_OK, ret);
		}

19 View Source File : SimpleIocTestAutoCreation.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestAutoCreationWithFactoryForInterfaceAndKey()
        {
            SimpleIoc.Default.Reset();
            const string key1 = "key1";
            SimpleIoc.Default.Register<ITestClreplaced>(
                () => new TestClreplaced1(),
                key1,
                true);

            var instances = SimpleIoc.Default.GetAllInstances<ITestClreplaced>();
            replacedert.AreEqual(1, instances.Count());

            var defaultInstance = SimpleIoc.Default.GetInstance<ITestClreplaced>(key1);
            replacedert.AreSame(defaultInstance, instances.ElementAt(0));
        }

19 View Source File : Sessions.cs
License : MIT License
Project Creator : kfrajtak

[TestMethod]
        public void GetSessions_MultipleEntry()
        {
            WindowsDriver<WindowsElement> calculatorSession = Utility.CreateNewSession(CommonTestSettings.CalculatorAppId);
            replacedert.IsNotNull(calculatorSession);

            WindowsDriver<WindowsElement> notepadSession = Utility.CreateNewSession(CommonTestSettings.NotepadAppId);
            replacedert.IsNotNull(notepadSession);

            int openSessionsCount = 0;

            using (HttpWebResponse response = WebRequest.Create(CommonTestSettings.WindowsApplicationDriverUrl + "/sessions").GetResponse() as HttpWebResponse)
            {
                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                JObject responseObject = JObject.Parse(responseString);
                replacedert.AreEqual(0, (int)responseObject["status"]);

                // There needs to be at least 2 open sessions after we create the 2 session above
                JArray capabilitiesArray = (JArray)responseObject["value"];
                openSessionsCount = capabilitiesArray.Count;
                replacedert.IsTrue(openSessionsCount >= 2);

                // Verify that both calculator and notepad sessions are created
                JToken calculatorSessionEntry = null;
                JToken notepadSessionEntry = null;
                foreach (var entry in capabilitiesArray.Children())
                {
                    if (entry["id"].ToString() == calculatorSession.SessionId.ToString())
                    {
                        calculatorSessionEntry = entry;
                    }
                    else if (entry["id"].ToString() == notepadSession.SessionId.ToString())
                    {
                        notepadSessionEntry = entry;
                    }

                    if (calculatorSessionEntry != null && notepadSessionEntry != null)
                    {
                        break;
                    }
                }

                replacedert.IsNotNull(calculatorSessionEntry);
                replacedert.AreEqual(CommonTestSettings.CalculatorAppId, calculatorSessionEntry["capabilities"]["app"].ToString());
                replacedert.IsNotNull(notepadSessionEntry);
                replacedert.AreEqual(CommonTestSettings.NotepadAppId, notepadSessionEntry["capabilities"]["app"].ToString());
            }

            // Close the newly created sessions
            calculatorSession.Quit();
            notepadSession.Quit();

            using (HttpWebResponse response = WebRequest.Create(CommonTestSettings.WindowsApplicationDriverUrl + "/sessions").GetResponse() as HttpWebResponse)
            {
                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                JObject responseObject = JObject.Parse(responseString);
                replacedert.AreEqual(0, (int)responseObject["status"]);

                // There needs to be 2 less sessions after we closed the 2 sessions above
                JArray capabilitiesArray = (JArray)responseObject["value"];
                replacedert.AreEqual(openSessionsCount - 2, capabilitiesArray.Count);
            }
        }

19 View Source File : SetupWizardTest3.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        [Priority(29)]
        public void FedExTestRate()
        {
            #region Arrange
            var store = _application.CurrentStore;
            var testSettings = _irepo.GetTestRate_FedExSettings();
            var servicecode = _irepo.GetTestRate_FedExServiceCode();
            var testSvc = new FedExProvider(testSettings, new Web.Logging.TextLogger())
                {
                    Settings =
                        {
                            ServiceCode = servicecode,
                            Packaging = (int)testSettings.DefaultPackaging
                        }
                };

            var testShipment = _irepo.GetTestRate_FedExShipment(store);
            var tesreplacedem = _irepo.GetTestRate_FedExShippableInfo();
            testShipment.Items.Add(tesreplacedem);
            #endregion

            //Act
            var rates = testSvc.RateShipment(testShipment);


            //replacedert
            if (rates == null)
                replacedert.AreEqual(1, 0);
            else
                replacedert.AreEqual(25, rates.FirstOrDefault().EstimatedCost);
        }

19 View Source File : TestUtility.cs
License : Apache License 2.0
Project Creator : CoatiSoftware

public static void OpenSolution(string solutionFilePath)
		{
			IVsSolution solutionService = (IVsSolution)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution));
			int ret = solutionService.OpenSolutionFile((uint)__VSSLNOPENOPTIONS.SLNOPENOPT_DontConvertSLN, solutionFilePath);

			DTE dte = (DTE)VsIdeTestHostContext.ServiceProvider.GetService(typeof(DTE));
			Console.WriteLine("opened solution contains " + dte.Solution.Projects.Count.ToString() + " projects");

			replacedert.AreEqual(VSConstants.S_OK, ret);
		}

19 View Source File : SetupWizardTest3.cs
License : MIT License
Project Creator : HotcakesCommerce

public void DeleteShippingMethod()
        {
            #region Arrange
            var method0 = _irepo.GetDeleteShippingMethod();
            var method1 = _application.OrderServices.ShippingMethods.FindAll(_application.CurrentStore.Id)
                            .FirstOrDefault(x => x.Name.Equals(method0));
            if (method1 == null) replacedert.AreEqual(0, 1);
            #endregion

            //Act/replacedert
            replacedert.IsTrue(_application.OrderServices.ShippingMethods.Delete(method1.Bvin));
        }

19 View Source File : SearcherTest.cs
License : MIT License
Project Creator : HotcakesCommerce

[TestMethod]
        public void CanScoreDoreplacedentsSearch()
        {
            long siteId = 0;
			string culture = "en-US";

            // Setup Objects
			Lexicon l = new Lexicon(new StaticLexicon());
			Searcher s = new Searcher(l, new StaticSearcher());
			SimpleTextIndexer indexer = new SimpleTextIndexer(s);

			indexer.Index(siteId, "1", 0, "Doreplacedent Red", "Red is the first doreplacedent. Red is a test.", culture);
			indexer.Index(siteId, "2", 0, "Doreplacedent Blue", "Blue is the second doreplacedent not Red like the first. Blue Blue doreplacedent is a sample", culture);
			indexer.Index(siteId, "3", 0, "Shakespeare: Julius Ceasar", "Et tu brute?", culture);
			indexer.Index(siteId, "4", 0, "Shakespeare: To Be or Not To Be", "To be or not to be doreplacedent Red Red Red Red Red Red Red", culture);
			indexer.Index(siteId, "5", 0, "Doc Brown", "The Flux Capacitor is what enables time travel. I fell off my toilet and hit my head. When I woke up, I drew this...", culture);

            string query = "doreplacedent red";
            int total = 0;
            List<SearchObject> results = s.DoSearch(query, 1, 10, culture, ref total);
            replacedert.IsNotNull(results);
            replacedert.AreEqual(3, results.Count);
            replacedert.AreEqual(4, results[0].Id, "First Doreplacedent should be #4");
            replacedert.AreEqual(1, results[1].Id, "Second Doreplacedent should be #1");
            replacedert.AreEqual(2, results[2].Id, "Last Doreplacedent should be #2");
        }

19 View Source File : SetupWizardTest0.cs
License : MIT License
Project Creator : HotcakesCommerce

public void CreateDefaultStore()
        {
            //TODO: Need to change CreateAndSetupStore function for CI

            //Arrange
            var store = _irepo.GetStore();

            //Act
            var resultstore = _application.AccountServices.CreateAndSetupStore();

            //replacedert
            if (resultstore == null)
                replacedert.AreEqual(1, 0);
            else
            {
                _application.CurrentStore = resultstore;

                #region replacedert

                replacedert.AreEqual(store.StoreName, resultstore.StoreName);
                //replacedert.AreEqual(store.CustomUrl, resultstore.CustomUrl);
                replacedert.AreEqual(store.Settings.MaxItemsPerOrder, resultstore.Settings.MaxItemsPerOrder);
                replacedert.AreEqual(store.Settings.MaxWeightPerOrder, resultstore.Settings.MaxWeightPerOrder);
                replacedert.AreEqual(store.Settings.AllowProductReviews, resultstore.Settings.AllowProductReviews);
                replacedert.AreEqual(store.Settings.ProductReviewModerate, resultstore.Settings.ProductReviewModerate);
                replacedert.AreEqual(store.Settings.ProductReviewCount, resultstore.Settings.ProductReviewCount);
                replacedert.AreEqual(store.Settings.MinumumOrderAmount, resultstore.Settings.MinumumOrderAmount);
                replacedert.AreEqual(store.Settings.LogoText, resultstore.Settings.LogoText);
                replacedert.AreEqual(store.Settings.UseLogoImage, resultstore.Settings.UseLogoImage);
                replacedert.AreEqual(store.Settings.LogoRevision, resultstore.Settings.LogoRevision);
                replacedert.AreEqual(store.Settings.FriendlyName, resultstore.Settings.FriendlyName);

                replacedert.AreEqual(store.Settings.MailServer.FromEmail, resultstore.Settings.MailServer.FromEmail);
                replacedert.AreEqual(store.Settings.MailServer.EmailForGeneral, resultstore.Settings.MailServer.EmailForGeneral);
                replacedert.AreEqual(store.Settings.MailServer.EmailForNewOrder, resultstore.Settings.MailServer.EmailForNewOrder);
                replacedert.AreEqual(store.Settings.MailServer.UseCustomMailServer, resultstore.Settings.MailServer.UseCustomMailServer);

                replacedert.AreEqual(store.Settings.PayPal.FastSignupEmail, resultstore.Settings.PayPal.FastSignupEmail);
                replacedert.AreEqual(store.Settings.PayPal.Currency, resultstore.Settings.PayPal.Currency);

                #endregion
            }
        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstancesWithInstanceGeneric()
        {
            const string key1 = "MyKey1";
            const string key2 = "MyKey2";
            const string key3 = "MyKey3";
            const string key4 = "MyKey4";
            const string key5 = "MyKey5";
            const string key6 = "MyKey6";

            var instanceOriginal1 = new TestClreplaced1();
            var instanceOriginal2 = new TestClreplaced1();
            var instanceOriginal3 = new TestClreplaced1();
            var instanceOriginal4 = new TestClreplaced1();
            var instanceOriginal5 = new TestClreplaced4();
            var instanceOriginal6 = new TestClreplaced4();

            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register(() => instanceOriginal1, key1);
            SimpleIoc.Default.Register(() => instanceOriginal2, key2);
            SimpleIoc.Default.Register(() => instanceOriginal3, key3);
            SimpleIoc.Default.Register(() => instanceOriginal4, key4);
            SimpleIoc.Default.Register(() => instanceOriginal5, key5);
            SimpleIoc.Default.Register(() => instanceOriginal6, key6);

            var instance1 = SimpleIoc.Default.GetInstance<TestClreplaced1>(key1);
            var instance2 = SimpleIoc.Default.GetInstance<TestClreplaced1>(key2);
            var instance3 = SimpleIoc.Default.GetInstance<TestClreplaced1>(key3);
            var instance4 = SimpleIoc.Default.GetInstance<TestClreplaced1>(key4);
            var instance5 = SimpleIoc.Default.GetInstance<TestClreplaced4>(key5);
            var instance6 = SimpleIoc.Default.GetInstance<TestClreplaced4>(key6);

            replacedert.IsNotNull(instance1);
            replacedert.IsNotNull(instance2);
            replacedert.IsNotNull(instance3);
            replacedert.IsNotNull(instance4);
            replacedert.IsNotNull(instance5);
            replacedert.IsNotNull(instance6);

            var allInstances = SimpleIoc.Default.GetAllInstances<TestClreplaced1>();
            replacedert.AreEqual(4, allInstances.Count());

            foreach (var instance in allInstances)
            {
                replacedert.IsNotNull(instance);

                if (instance.Equals(instance1))
                {
                    instance1 = null;
                }

                if (instance.Equals(instance2))
                {
                    instance2 = null;
                }

                if (instance.Equals(instance3))
                {
                    instance3 = null;
                }

                if (instance.Equals(instance4))
                {
                    instance4 = null;
                }

                if (instance.Equals(instance5))
                {
                    instance5 = null;
                }

                if (instance.Equals(instance6))
                {
                    instance6 = null;
                }
            }

            replacedert.IsNull(instance1);
            replacedert.IsNull(instance2);
            replacedert.IsNull(instance3);
            replacedert.IsNull(instance4);
            replacedert.IsNotNull(instance5);
            replacedert.IsNotNull(instance6);
        }

See More Examples