// ReSharper restore PossibleMultipleEnumeration private void Page(ICollectionFacet testArrayFacet, INakedObjectAdapter collection, object first) { INakedObjectAdapter pagedCollection = testArrayFacet.Page(1, 1, collection, manager, false); Assert.IsTrue(((IEnumerable)pagedCollection.Object).Cast <string>().Count() == 1); Assert.AreSame(((IEnumerable)pagedCollection.Object).Cast <string>().First(), first); }
// ReSharper disable PossibleMultipleEnumeration private void ValidateCollection(ICollectionFacet collectionFacet, INakedObjectAdapter collection, IEnumerable <object> objects) { INakedObjectAdapter[] collectionAsEnumerable = collectionFacet.AsEnumerable(collection, manager).ToArray(); Assert.AreEqual(collectionAsEnumerable.Count(), objects.Count()); IEnumerable <Tuple <object, object> > zippedCollections = collectionAsEnumerable.Zip(objects, (no, o1) => new Tuple <object, object>(no.Object, o1)); zippedCollections.ForEach(t => Assert.AreSame(t.Item1, t.Item2)); }
public void TwoVarsCanReferenceSameObject() { var book1 = GetBook("Book 1"); var book2 = book1;; Assert.AreSame(book1, book2); Assert.IsTrue(Object.ReferenceEquals(book1, book1)); }
public void IsObjectsReferToSameObject() { var obj1 = new object(); var obj2 = obj1; var obj3 = obj1; Assert.AreSame(obj2, obj3); }
public void TestMethod1() { var card = new Card(); var deck = new Deck(new[] { card }); var fetched = deck.GetCards(1); var end = deck.EntireDeck; Assert.AreEqual(0, end.Count()); Assert.AreSame(fetched.FirstOrDefault(), card); }
public void GenerateInterfaceCreatesPlaceHolder() { MockAspNetService mockAspNet = new MockAspNetService(); PlaceHolder holder = new PlaceHolder(); mockAspNet.FindControlResults.Add("DriverPageContentPlaceHolder", holder); TestDriverPage page = new TestDriverPage(mockAspNet); page.GenerateInterface(); UnitTestAssert.AreSame(holder, page.ContentPlaceHolder); }
public void WhenCreatingPageWithAppPath_ShouldUseItToCreateCommandExecutor() { //arrange var mockExecutor = new Mock <IBrowserCommandExecutor>(); var mockExecutorFactory = new Mock <IBrowserCommandExecutorFactory>(); mockExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor( It.Is <string>(u => u == "http://myapppath/"), It.IsAny <HtmlPage>()) ).Returns(mockExecutor.Object); ServiceLocator.BrowserCommandExecutorFactory = mockExecutorFactory.Object; //act var htmlPage = new HtmlPage(new Uri("http://myapppath")); //assert UnitTestAssert.AreSame(mockExecutor.Object, htmlPage.BrowserCommandExecutor); }
public void EvaluateReturnsListWithASingleTestThatMatchesTheTag() { MethodInfo method = typeof(SampleWebTestClass).GetMethod("SampleWebTestMethod1"); Dictionary <string, List <MethodInfo> > tags = new Dictionary <string, List <MethodInfo> >(); tags.Add("foo", new List <MethodInfo>() { method }); WebTestTagExpressionEvaluator evaluator = new WebTestTagExpressionEvaluator(); List <MethodInfo> filtered = evaluator.Evaluate( "foo", BrowserVersions.All, new List <MethodInfo>(), new Dictionary <MethodInfo, BrowserVersions>(), tags); UnitTestAssert.AreEqual(1, filtered.Count); UnitTestAssert.AreSame(method, filtered[0]); }
public void AuditUsingSpecificTypeAuditorServiceActionWithParms() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestService foo = GetTestService("Foo Service"); ITestObject fooObj = GetTestService("Foos").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int fooCalledCount = 0; FooAuditor.Auditor.serviceActionInvokedCallback = (p, a, s, b, pp) => { Assert.AreEqual("sven", p.Identity.Name); Assert.AreEqual("AnActionWithParms", a); Assert.AreEqual("Foo Service", s); Assert.IsFalse(b); Assert.AreEqual(2, pp.Length); Assert.AreEqual(1, pp[0]); Assert.AreSame(fooObj.NakedObject.Object, pp[1]); fooCalledCount++; }; foo.GetAction("An Action With Parms").InvokeReturnObject(1, fooObj); Assert.AreEqual(1, fooCalledCount, "expect foo auditor to be called"); }
public void AuditUsingSpecificTypeAuditorActionWithParms() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestObject foo = GetTestService("Foos").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int fooCalledCount = 0; FooAuditor.Auditor.actionInvokedCallback = (p, a, o, b, pp) => { Assert.AreEqual("sven", p.Identity.Name); Assert.AreEqual("AnActionWithParms", a); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Foo", o.GetType().FullName); Assert.IsFalse(b); Assert.AreEqual(2, pp.Count()); Assert.AreEqual(1, pp[0]); Assert.AreSame(foo.NakedObject.Object, pp[1]); fooCalledCount++; }; foo.GetAction("An Action With Parms").InvokeReturnObject(1, foo.NakedObject.Object); Assert.AreEqual(1, fooCalledCount, "expect foo auditor to be called"); }
public void ReferenceEquality() { object act = new object(); object exp = new object(); // MSTest MSTestAssert.AreSame(exp, act, "Some context"); // Assert.AreSame failed. Some context // NUnit Assert.That(act, Is.SameAs(exp), () => "Some context"); // Some context // Expected: same as <System.Object> // But was: <System.Object> // XUnit XUnitAssert.Same(exp, act); // Assert.Same() Failure // Expected: Object { } // Actual: Object { } // Fluent act.Should().BeSameAs(exp, "SOME REASONS"); // Expected act to refer to System.Object (HashCode=63566392) because SOME REASONS, but found System.Object (HashCode=24004906). // Shouldly act.ShouldBeSameAs(exp, "Some context"); // act // should be same as // System.Object (24965396) // but was // System.Object (37190989) // // Additional Info: // Some context }
// ReSharper restore PossibleMultipleEnumeration private void FirstElement(ICollectionFacet collectionFacet, INakedObjectAdapter collection, object first) { Assert.AreSame(first, collectionFacet.AsEnumerable(collection, manager).First().Object); }
public void PydInPackage() { PythonPaths.Python27.AssertInstalled(); var outputPath = TestData.GetTempPath(); Console.WriteLine("Writing to: " + outputPath); // run the analyzer using (var output = ProcessOutput.RunHiddenAndCapture("Microsoft.PythonTools.Analyzer.exe", "/python", PythonPaths.Python27.InterpreterPath, "/lib", TestData.GetPath(@"TestData\PydStdLib"), "/version", "2.7", "/outdir", outputPath, "/indir", CompletionDB, "/log", "AnalysisLog.txt")) { output.Wait(); Console.WriteLine("* Stdout *"); foreach (var line in output.StandardOutputLines) { Console.WriteLine(line); } Console.WriteLine("* Stderr *"); foreach (var line in output.StandardErrorLines) { Console.WriteLine(line); } Assert.AreEqual(0, output.ExitCode); } var fact = InterpreterFactoryCreator.CreateAnalysisInterpreterFactory(new Version(2, 7)); var paths = new List <string> { outputPath }; paths.AddRange(Directory.EnumerateDirectories(outputPath)); var typeDb = new PythonTypeDatabase(fact, paths); var module = typeDb.GetModule("Package.winsound"); Assert.IsNotNull(module, "Package.winsound was not analyzed"); var package = typeDb.GetModule("Package"); Assert.IsNotNull(package, "Could not import Package"); var member = package.GetMember(null, "winsound"); Assert.IsNotNull(member, "Could not get member Package.winsound"); Assert.AreSame(module, member); module = typeDb.GetModule("Package._testcapi"); Assert.IsNotNull(module, "Package._testcapi was not analyzed"); package = typeDb.GetModule("Package"); Assert.IsNotNull(package, "Could not import Package"); member = package.GetMember(null, "_testcapi"); Assert.IsNotNull(member, "Could not get member Package._testcapi"); Assert.IsNotInstanceOfType(member, typeof(CPythonMultipleMembers)); Assert.AreSame(module, member); module = typeDb.GetModule("Package.select"); Assert.IsNotNull(module, "Package.select was not analyzed"); package = typeDb.GetModule("Package"); Assert.IsNotNull(package, "Could not import Package"); member = package.GetMember(null, "select"); Assert.IsNotNull(member, "Could not get member Package.select"); Assert.IsInstanceOfType(member, typeof(CPythonMultipleMembers)); var mm = (CPythonMultipleMembers)member; AssertUtil.ContainsExactly(mm.Members.Select(m => m.MemberType), PythonMemberType.Module, PythonMemberType.Constant, PythonMemberType.Class ); Assert.IsNotNull(mm.Members.Contains(module)); try { // Only clean up if the test passed Directory.Delete(outputPath, true); } catch { } }
void executor_TestcaseExecuting(object sender, TestcaseExecutionEventArgs e) { UniTestAssert.AreSame(_executor, sender); UniTestAssert.AreEqual("TestWebTestClassName.TestWebTestMethodName", e.WebTestName); }
void executor_TestRunFinished(object sender, TestRunFinishedEventArgs e) { UniTestAssert.AreSame(_executor, sender); UniTestAssert.AreEqual("Test Log", e.TestLog); }
void executor_TestRunStarted(object sender, EventArgs e) { UniTestAssert.AreSame(_executor, sender); }