示例#1
0
 public void PropertyValueProviderFqn()
 {
     var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
     var testFilter = new TFSTestFilter(null);
     var obj = TFSTestFilter.PropertyValueProvider(tc, "FullyQualifiedName");
     Assert.AreSame("Test1", obj);
 }
示例#2
0
文件: Trade.cs 项目: andy-uq/Echo
        public void Buy()
        {
            var test = new TestCase();

            test.Buyer.Bank = 10000;

            Auction auction = test.CreateAuction();
            Assert.AreEqual(1000, auction.Quantity);

            uint auctionQuantity = auction.Quantity;
            IItem item;
            while (auctionQuantity > 100)
            {
                item = test.Buyer.Buy(auction, 100);
                auctionQuantity -= 100;

                Assert.AreEqual(auctionQuantity, auction.Quantity);
                Assert.AreEqual(100, item.Quantity);
                Assert.AreEqual(test.Buyer, item.Owner);
                Assert.AreEqual(2, test.Buyer.Assets.Count);
            }

            item = test.Buyer.Buy(auction, 100);
            Assert.AreEqual(test.Buyer, item.Owner);

            CollectionAssert.DoesNotContain(test.Seller.Assets, auction.Item);
            Assert.AreEqual(2, test.Buyer.Assets.Count);
            Assert.AreEqual(1, test.Seller.Assets.Count);
        }
示例#3
0
		public static void  CheckHits_(Query query, System.String defaultFieldName, Searcher searcher, int[] results, TestCase testCase)
		{
            Hits hits = searcher.Search(query);
			
            System.Collections.Hashtable correct = new System.Collections.Hashtable();
            for (int i = 0; i < results.Length; i++)
            {
                correct.Add((System.Int32) results[i], null);
            }
			
            System.Collections.Hashtable actual = new System.Collections.Hashtable();
            for (int i = 0; i < hits.Length(); i++)
            {
                actual.Add((System.Int32) hits.Id(i), null);
            }
			
            //Assert.AreEqual(correct, actual, query.ToString(defaultFieldName));
            if (correct.Count != 0)
            {
                System.Collections.IDictionaryEnumerator iter = correct.GetEnumerator();
                bool status = false;
                while (iter.MoveNext())
                {
                    status = actual.ContainsKey(iter.Key);
                    if (status == false)
                        break;
                }
                Assert.IsTrue(status, query.ToString(defaultFieldName));
            }
        }
示例#4
0
 public void ExceptionHandlerIsCalledWhenExceptionMatches_AlternateHandler()
 {
     ExceptionHandlerCalledClass fixture = new ExceptionHandlerCalledClass();
     ITest testCase = new TestCase("ThrowsArgumentException_AlternateHandler", fixture);
     testCase.Run();
     Assert.That(fixture.HandlerCalled, Is.False, "Base Handler should not be called");
     Assert.That(fixture.AlternateHandlerCalled, "Alternate Handler should be called");
 }
 public void ExceptionHandlerIsNotCalledWhenExceptionDoesNotMatch()
 {
     ExceptionHandlerCalledClass fixture = new ExceptionHandlerCalledClass();
     ITest testCase = new TestCase("ThrowsApplicationException", fixture);
     testCase.Run();
     Assert.That(fixture.HandlerCalled, Is.False, "Base Handler should not be called");
     Assert.That(fixture.AlternateHandlerCalled, Is.False, "Alternate Handler should not be called");
 }
示例#6
0
 public void PropertyValueProviderCategoryFail()
 {
     var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
     tc.AddTrait("Category", "CI");
     var testFilter = new TFSTestFilter(null);
     var obj = TFSTestFilter.PropertyValueProvider(tc, "Garbage");
     Assert.Null(obj);
 }
示例#7
0
文件: Trade.cs 项目: andy-uq/Echo
        public void CreateAuction()
        {
            var test = new TestCase();
            Auction auction = test.CreateAuction();

            Assert.AreEqual(test.Seller, auction.Owner);
            CollectionAssert.DoesNotContain(test.Seller.Assets, auction.Item);
        }
示例#8
0
        public void PropertyValueProviderCategoryWithNoTraits()
        {
            CheckTraitsSupported();

            var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
            var testFilter = new TFSTestFilter(null);
            var obj = TFSTestFilter.PropertyValueProvider(tc, "TestCategory");
            Assert.IsNull(obj);
        }
示例#9
0
 public void TestTextManipulationWithMnemonicNoEllipsing(TestCase testCase)
 {
     DecentGroupBoxWrapper gb = new DecentGroupBoxWrapper { Width = testCase.Width, UseMnemonic = true, AutoEllipsis = false};
     gb.Text = testCase.Text;
     Assert.IsFalse(gb.AutoEllipsis, "auto ellipse setting");
     Assert.IsTrue(gb.UseMnemonic, "use mnemonic setting");
     Assert.That(gb.Text, Is.EqualTo(testCase.Text), "Raw text TestCase: " + testCase.Text);
     Assert.That(gb.ManipulatedText, Is.EqualTo(testCase.Expected), "Manipulated text TestCase: " + testCase.Text);
 }
 public void FailsWhenAlternateHandlerIsNotFound()
 {
     ExceptionHandlerCalledClass fixture = new ExceptionHandlerCalledClass();
     ITest testCase = new TestCase("MethodWithBadHandler", fixture);
     TestResult result = testCase.Run();
     Assert.That(result.ResultState, Is.EqualTo(ResultState.Failure));
     Assert.That(result.Message, Is.EqualTo(
         "The specified exception handler DeliberatelyMissingHandler was not found" ));
 }
        public void CanRegisterEvents()
        {
            var sw = new StringWriter();
            var testCase =new TestCase(sw);
            var eventData = new TestEvent {Name = "Hello"};

            EventManager.Register<TestEvent>(testCase.ProcessEvent);
            EventManager.Raise(eventData);
            Assert.AreEqual(sw.ToString(), eventData.Name);
        }
示例#12
0
        public void PropertyValueProviderCategoryWithOneCategory()
        {
            CheckTraitsSupported();

            var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
            tc.AddTrait("Category", "CI");
            var testFilter = new TFSTestFilter(null);
            var obj = TFSTestFilter.PropertyValueProvider(tc, "TestCategory");
            Assert.AreSame("CI", obj);
        }
        /// <summary>
        ///     Parameterised unit test for <cref>SortingAlgorithmModule.SortThatWorks</cref>.
        /// </summary>
        /// <remarks>
        ///     This is expected to succeed.
        /// </remarks>
        /// <param name="testCase"></param>
        public static void ParameterisedUnitTestForReassemblyOfPermutedMonotonicIncreasingSequenceByCorrectSortingAlgorithm(TestCase testCase)
        {
            Console.WriteLine("[{0}]", String.Join(", ", testCase.PermutedSequence));

            var sortedSequence =
                SortingAlgorithmModule.SortThatWorks(testCase.PermutedSequence);

            Assert.IsTrue(
                sortedSequence.SequenceEqual(testCase.OriginalMonotonicIncreasingSequence));
        }
        public void MultipleSubscribersAreCalled()
        {
            var sw = new StringWriter();
            var testCase = new TestCase(sw);
            var testCase2 = new TestCase(sw);
            var eventData = new TestEvent { Name = "Hello" };

            EventManager.Register<TestEvent>(testCase.ProcessEvent);
            EventManager.Register<TestEvent>(testCase2.ProcessEvent);
            EventManager.Raise(eventData);
            Assert.AreEqual(sw.ToString(), eventData.Name + eventData.Name);
        }
示例#15
0
文件: Trade.cs 项目: andy-uq/Echo
        public void ExpireAuction()
        {
            var test = new TestCase();
            Auction auction = test.CreateAuction();

            Assert.AreEqual(test.Seller, auction.Owner);
            CollectionAssert.DoesNotContain(test.Seller.Assets, auction.Item);

            while (auction.Expires > 0)
                test.Universe.Tick();

            CollectionAssert.Contains(test.Seller.Assets, auction.Item);
        }
示例#16
0
        public void PropertyValueProviderCategoryWithMultipleCategories()
        {
            CheckTraitsSupported();

            var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
            tc.AddTrait("Category", "CI");
            tc.AddTrait("Category", "MyOwn");
            var testFilter = new TFSTestFilter(null);
            var obj = TFSTestFilter.PropertyValueProvider(tc, "TestCategory") as string[];
            Assert.IsNotNull(obj);
            Assert.AreEqual(obj.Length,2);
            Assert.AreSame("CI", obj[0]);
            Assert.AreSame("MyOwn",obj[1]);
        }
示例#17
0
文件: Trade.cs 项目: andy-uq/Echo
        public void BuyPartial()
        {
            var test = new TestCase();

            test.Buyer.Bank = 10000;

            Auction auction = test.CreateAuction();
            Assert.AreEqual(1000, auction.Quantity);

            IItem item = test.Buyer.Buy(auction, 100);

            Assert.AreEqual(100, item.Quantity);
            Assert.AreEqual(test.Buyer, item.Owner);
            CollectionAssert.Contains(test.Buyer.Assets, item);
        }
        private void CheckTestCase(TestCase testCase)
        {
            Assert.That(testCase.FullyQualifiedName, Is.EqualTo(FakeTestData.FullyQualifiedName));
            Assert.That(testCase.DisplayName, Is.EqualTo(FakeTestData.DisplayName));
            Assert.That(testCase.Source, Is.SamePath(FakeTestData.AssemblyPath));

            Assert.That(testCase.CodeFilePath, Is.SamePath(FakeTestData.CodeFile));
            Assert.That(testCase.LineNumber, Is.EqualTo(FakeTestData.LineNumber));

            // Check traits using reflection, since the feature was added
            // in an update to VisualStudio and may not be present.
            if (TraitsFeature.IsSupported)
            {
                var traitList = testCase.GetTraits().Select(trait => trait.Name + ":" + trait.Value).ToList();

                Assert.That(traitList, Is.EquivalentTo(new[] { "Category:super", "Category:cat1", "Priority:medium" }));
            }
        }
示例#19
0
 public void TestThatTestCaseWithUnspecifiedOriginFindsOriginAssemblyInTestMethod()
 {
     var tc = new TestCase(_testCase.TestMethod, new MSTestTestFramework().AsRelated());
     Assert.AreSame(tc.TestMethod.Module.Assembly, _testCase.Origin.Assembly);
 }
        public void StringBasedRepsonsesToRowState(TestCase tc)
        {
            Mock<SummaryTextComponent> baseComponent = new Mock<SummaryTextComponent>();
            StringBuilder sb = new StringBuilder();
            baseComponent.Setup(c => c.BuildSummary()).Returns(sb);

            Mock<Host> host = ObjectFactory.BuiltObject<Host>(ObjectBuilderType.ClearwaterHost, id);
            Mock<ILicenseStatus> ls = new Mock<ILicenseStatus>();
            ls.Setup(l => l.CurrentState).Returns(tc.State);
            ls.Setup(l =>l.ExpiryDate).Returns(tc.Expiry);
            ls.Setup(l => l.LicenseExpiresIn).Returns(tc.ExpiresIn);

            CheckableDataGridViewRow row = new LicenseDataGridViewRow(host.Object, ls.Object);

            LicenseManagerSummaryLicenseExpiresDecorator decorator = new LicenseManagerSummaryLicenseExpiresDecorator(baseComponent.Object, row);
            decorator.BuildSummary();

            Assert.That(sb.ToString().Contains(Messages.LICENSE_MANAGER_SUMMARY_LICENSE_EXPIRES));
            Assert.That(sb.ToString().Contains(tc.Contains));

            baseComponent.Verify(c=>c.BuildSummary(), Times.Once());
        }
示例#21
0
		private void checkMac(IMac mac, TestCase testCase)
		{
			byte[] generatedMac = new byte[mac.GetMacSize()];
			mac.DoFinal(generatedMac, 0);
			if (!AreEqual(testCase.getTag(), generatedMac))
			{
				Fail("Failed " + testCase.getName() + " - expected " + Hex.ToHexString(testCase.getTag()) + " got "
				     + Hex.ToHexString(generatedMac));
			}
		}
示例#22
0
		private void testSingleByte(IMac mac, TestCase testCase)
		{
			byte[] ad = testCase.getAd();
			for (int i = 0; i < ad.Length; i++)
			{
				mac.Update(ad[i]);
			}
			checkMac(mac, testCase);
		}
示例#23
0
		private void testMultibyte(IMac mac, TestCase testCase)
		{
			mac.BlockUpdate(testCase.getAd(), 0, testCase.getAd().Length);
			checkMac(mac, testCase);
		}
示例#24
0
 public void TestXvaValidation(TestCase tc)
 {
     ApplianceExistsCheckStaticOverrides checker = new ApplianceExistsCheckStaticOverrides(directoryName, fileName, ApplianceCheck.FileExtension.xva)
     {
         DirectoryExistsValue = tc.DirFound,
         FileExistsValue = tc.FileFound
     };
     checker.Validate();
     Assert.That(checker.IsValid, Is.EqualTo(tc.Valid), "Is valid test -> " + tc);
     Assert.That(checker.DirectoryExistsCalls, Is.EqualTo(0), "dir exists calls -> " + tc);
     Assert.That(checker.FileExistsCalls, Is.EqualTo(1), "file exists calls -> " + tc);
 }
 /// <summary>
 /// Assert that a 'TestSuite' trait with the provided value exists.
 /// </summary>
 /// <param name="testCase">The testcase which contains the trait collection in question</param>
 /// <param name="value">The test suite value the looked-up trait should have</param>
 private void AssertTestSuite(TestCase testCase, string value)
 {
     AssertTrait(testCase, VSTestModel.TestSuiteTrait, value);
 }
 /// <summary>
 /// Assert that a trait with the provided name and value exists.
 /// </summary>
 /// <param name="testCase">The testcase which contains the trait collection in question</param>
 /// <param name="name">The name of the trait to look for</param>
 /// <param name="value">The value the looked-up trait should have</param>
 private void AssertTrait(TestCase testCase, string name, string value)
 {
     Assert.That(testCase.Traits.Any((trait) => { return (trait.Name == name) && (trait.Value == value); }), Is.True);
 }
        /// <summary>
        /// Asserts general test case details
        /// </summary>
        /// <param name="testCase">The test case to test</param>
        /// <param name="qualifiedName">The expected qualified name of the test case</param>
        /// <param name="sourceFile">The expected source file path of the test case or null if not available</param>
        /// <param name="lineNumber">The expected line number of the test case or -1 if not available</param>
        private void AssertTestDetails(TestCase testCase, QualifiedNameBuilder qualifiedName, string sourceFile, int lineNumber)
        {
            Assert.That(testCase.DisplayName, Is.EqualTo(qualifiedName.Peek()));
            Assert.That(testCase.FullyQualifiedName, Is.EqualTo(qualifiedName.ToString()));

            string suite = qualifiedName.Pop().ToString();
            if (!string.IsNullOrEmpty(suite))
            {
                AssertTestSuite(testCase, suite);
            }
            else
            {
                // The default 'Master Test Suite' trait value should be available
                AssertTrait(testCase, VSTestModel.TestSuiteTrait);
            }

            if (!string.IsNullOrEmpty(sourceFile))
            {
                Assert.That(testCase.CodeFilePath, Is.EqualTo(sourceFile));
            }

            if (lineNumber > -1)
            {
                Assert.That(testCase.LineNumber, Is.EqualTo(lineNumber));
            }
        }
示例#28
0
 public void FindFirstTestCase()
 {
     _testCase = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddBasic());
 }
示例#29
0
 public void TestThatTestCaseExposesFramework()
 {
     var tc = new TestCase(_testCase.TestMethod, new MSTestTestFramework().AsRelated());
     Assert.IsInstanceOf<MSTestTestFramework>(tc.Framework);
 }
 /// <summary>
 /// Asserts general test case details
 /// </summary>
 /// <param name="testCase">The test case to test</param>
 /// <param name="qualifiedName">The expected qualified name of the test case</param>
 private void AssertTestDetails(TestCase testCase, QualifiedNameBuilder qualifiedName)
 {
     AssertTestDetails(testCase, qualifiedName, null, -1);
 }