コード例 #1
1
ファイル: ThisFun.cs プロジェクト: nlhepler/mono
 public static void Main(String[] args) {
   FooBar fb = new FooBar();
   IList<int> list = new LinkedList<int>();
   list.AddAll(new int[] { 2, 3, 5, 7, 11 });
   list.Map<double>(fb).Apply(Console.WriteLine);
   list.Apply(fb);
 }
コード例 #2
0
    static void Main()
    {
        FooBar fooBar = new FooBar();

        Foo myBarFoo = new director_smartptr_MyBarFoo();

        check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()");
        check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()");
        check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()");

        Foo myFoo = myBarFoo.makeFoo();

        check(myFoo.pong(), "Foo::pong();Foo::ping()");
        check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()");
        check(myFoo.upcall(new FooBar()), "Bar::Foo2::Foo2Bar()");

        Foo myFoo2 = new Foo().makeFoo();

        check(myFoo2.pong(), "Foo::pong();Foo::ping()");
        check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");

        FooDerived myBarFooDerived = new director_smartptr_MyBarFooDerived();

        check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()");
        check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()");
        check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()");
    }
コード例 #3
0
ファイル: UnitTests.cs プロジェクト: kouweizhong/Sop
        public void UserManagedDisposeTest()
        {
            Sop.ObjectServer server = Sop.ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta");
            var           df        = new Sop.StoreFactory();// {AutoDisposeItem = false};
            const int     ItemCount = 50000;
            List <FooBar> fooBars   = new List <FooBar>(ItemCount);
            string        s         = string.Format("Collection{0}", 1);
            var           sortDict  = df.Get <int, FooBar>(server.SystemFile.Store, s);//, null, false);    // FooBar is disposable, IsDataInKeySegment = false.

            //sortDict.AutoDisposeItem = true;
            for (int i = 0; i < ItemCount; i++)
            {
                var v = new FooBar()
                {
                    Foo = string.Format("Hello World {0}", i)
                };
                sortDict.Add(i, v);
                fooBars.Add(v);
            }
            server.Commit();
            foreach (FooBar fb in fooBars)
            {
                fb.Dispose();
            }
        }
コード例 #4
0
        public void ShouldAppendEventToPpenddingEventsQueue()
        {
            var expectedAggregatedId = Guid.NewGuid().ToString();
            var fisrtEvent           = new FakeCelebrityWasCreatedEvent(expectedAggregatedId, new { Id = expectedAggregatedId, Foo = "Bar", Bar = "Foo" });
            var events = new Queue <ICelebrityEvent>();

            events.Enqueue(fisrtEvent);

            var state  = new FooBar(expectedAggregatedId);
            var fooBar = events.Reduce <FooBar>(state, (a, b) =>
            {
                a.Foo = b.Data.Foo;
                a.Bar = b.Data.Bar;
                return(state);
            });

            fooBar.RevertPropertyValues();

            var pendingEvent = fooBar.PendingEvents.Should().HaveCount(1).And.Subject.First();

            pendingEvent.AggregatedId.Should().Be(expectedAggregatedId);

            var data = (object)pendingEvent.Data;

            data.Should().Be(new { Id = expectedAggregatedId, Foo = "Foo", Bar = "Bar" });
        }
コード例 #5
0
    static void engine_AfterReadRecord(EngineBase engine, FileHelpers.Events.AfterReadEventArgs <object> e)
    {
        FooBar fooBar = e.Record as FooBar;

        fooBar.ColumnA_Two = fooBar.ColumnA_One;
        fooBar.ColumnB_Two = fooBar.ColumnB_One;
    }
コード例 #6
0
ファイル: ClientGraphQueries.cs プロジェクト: radtek/ravendb
 public void CanGraphQuery()
 {
     using (var store = GetDocumentStore())
     {
         using (var session = store.OpenSession())
         {
             var bar = new Bar {
                 Name = "Barvazon"
             };
             var barId = "Bars/1";
             session.Store(bar, barId);
             session.Store(new Foo
             {
                 Name = "Foozy",
                 Bars = new List <string> {
                     barId
                 }
             });
             session.SaveChanges();
             FooBar res = session.Advanced.GraphQuery <FooBar>("match (Foo)-[Bars as _]->(Bars as Bar)").With("Foo", session.Query <Foo>()).Single();
             Assert.Equal(res.Foo.Name, "Foozy");
             Assert.Equal(res.Bar.Name, "Barvazon");
         }
     }
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: aquarius20th/WPF_Gimela
        public static void Serialize()
        {
            // Serialize (from Object to JsonString)
            var obj = new
            {
                Name    = "Foo",
                Age     = 30,
                Address = new
                {
                    Country = "Japan",
                    City    = "Tokyo"
                },
                Like = new[] { "Microsoft", "Xbox" }
            };
            // {"Name":"Foo","Age":30,"Address":{"Country":"Japan","City":"Tokyo"},"Like":["Microsoft","Xbox"]}
            var jsonStringFromObj = DynamicJsonConvert.SerializeObject(obj);

            // [{"foo":"fooooo!","bar":1000},{"foo":"orz","bar":10}]
            var foobar = new FooBar[] {
                new FooBar {
                    foo = "fooooo!", bar = 1000
                },
                new FooBar {
                    foo = "orz", bar = 10
                }
            };
            var jsonFoobar = DynamicJsonConvert.SerializeObject(foobar);
        }
コード例 #8
0
    public virtual void DoSomething()
    {
        // Manipulate SomeVar here
        var someVar = ....;

        SomeVar = someVar;
    }
コード例 #9
0
ファイル: ExampleTest.cs プロジェクト: gheyret/DynaJson
        public void ConvertTypes()
        {
            var arrayJson  = JsonObject.Parse("[1,2,3]");
            var objectJson = JsonObject.Parse(@"{""foo"":""json"",""bar"":100}");

            var array1 = arrayJson.Deserialize <int[]>(); // dynamic{int[]}

            Assert.AreEqual(typeof(int[]), array1.GetType());
            var array2 = (int[])arrayJson; // int[]

            Assert.AreEqual(typeof(int[]), array2.GetType());
            Assert.AreEqual(6, array2.Sum());
            var array3 = (List <int>)arrayJson;

            Assert.AreEqual(6, array3.Sum());

            var expected = new FooBar
            {
                foo = "json",
                bar = 100
            };
            // mapping by public property name
            var foobar1 = objectJson.Deserialize <FooBar>();

            Assert.AreEqual(expected, foobar1);
            var foobar2 = (FooBar)objectJson;

            Assert.AreEqual(expected, foobar2);
            FooBar foobar3 = objectJson;

            Assert.AreEqual(expected, foobar3);
        }
コード例 #10
0
        public async Task <IActionResult> Edit(int id, [Bind("FooBarId,FooBarValue")] FooBar fooBar)
        {
            if (id != fooBar.FooBarId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _uow.FooBars.Update(fooBar);
                    await _uow.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FooBarExists(fooBar.FooBarId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fooBar));
        }
コード例 #11
0
            public void Should_convert_to_derived_correctly()
            {
                var source = new FooBar();
                var dest   = Mapper.Map(source, source.GetType(), typeof(FooDto));

                dest.ShouldBeOfType <FooBarDto>();
            }
コード例 #12
0
        public void Test(int n)
        {
            string r = string.Join("", Enumerable.Range(0, n * 2).Select(i => i % 2 == 0 ? "foo" : "bar"));

            var fooBar = new FooBar(n);

            TextWriter tw = new StringWriter();

            CancellationTokenSource cts     = new CancellationTokenSource(5000);
            ParallelOptions         options = new ParallelOptions {
                CancellationToken = cts.Token
            };

            Parallel.ForEach(Enumerable.Range(0, 2), options, i =>
            {
                if (i % 2 == 0)
                {
                    fooBar.Foo(() => tw.Write("foo"));
                }
                else
                {
                    fooBar.Bar(() => tw.Write("bar"));
                }
            });

            string result = tw.ToString();

            Assert.True(0 == r.CompareTo(result));
        }
コード例 #13
0
        public void ConvertTo()
        {
            // a JSON objects to a C# object
            var jsonObject = JsonObject.Parse(@"{""foo"":""json"",""bar"":100}");
            var expected   = new FooBar
            {
                foo = "json",
                bar = 100
            };
            var foobar = (FooBar)jsonObject; // FooBar

            Assert.AreEqual(expected, foobar);
            var c1 = foobar.bar; // 100

            Assert.AreEqual(100, c1);

            // to a C# dictionary
            var dict1 = (Dictionary <string, dynamic>)jsonObject;
            var c2    = dict1["bar"];

            Assert.AreEqual(100, c2);

            // a JSON array to a C# array
            var jsonArray = JsonObject.Parse("[1,2,3]");
            var array     = (int[])jsonArray; // int[]

            Assert.AreEqual(typeof(int[]), array.GetType());
            Assert.AreEqual(6, array.Sum());

            // to a C# list
            var list = (List <int>)jsonArray;
            var sum2 = list.Sum();

            Assert.AreEqual(6, sum2);
        }
コード例 #14
0
        public void Implicit_Mapping_MapFrom()
        {
            _mappingEngine.CreateMap <Foo, Bar>();
            //maps SomeBar from SomeFoo implicitly using the Foo -> Bar mapping,
            //and because both share Child and Foos properties, the above implicit mapping should work for them too
            _mappingEngine.CreateMap <FooBar, FooBar>()
            .ForMember(x => x.SomeBar, opt => opt.MapFrom(x => x.SomeFoo));

            var input = new FooBar()
            {
                SomeFoo = new Foo()
                {
                    Child = new Foo()
                    {
                        Name = "child"
                    },
                    Foos = new[] { new Foo()
                                   {
                                       Name = "blah1"
                                   }, new Foo()
                                   {
                                       Name = "blah2"
                                   } },
                    Name = "test"
                }
            };

            var output = _mappingEngine.Map <FooBar>(input);

            Assert.AreEqual(input.SomeFoo.Name, output.SomeBar.Name);
            Assert.AreEqual(input.SomeFoo.Child.Name, output.SomeBar.Child.Name);
            Assert.AreEqual(input.SomeFoo.Foos.Count(), output.SomeBar.Foos.Count());
        }
コード例 #15
0
        public void TestMethodResolution()
        {
            // 25.1.7 Overloading in generic classes
            // Methods, constructors, indexers, and operators within a generic class declaration can be overloaded.
            // While signatures as declared must be unique, it is possible that substitution of type arguments
            // results in identical signatures.
            // In such a situation, overload resolution will pick the most specific one (14.4.2.2).
            // 14.4.2.2 Better function member
            // If one of MP and MQ is non-generic, but the other is generic, then the non-generic is better.
            var b = new FooBar <int>();

            Assert.AreEqual("Foo(int)", b.Foo(0));
            Assert.AreEqual("Bar(int)", b.Bar(0));
            Assert.AreEqual("Bar2(T)", b.Bar2(0));

            // 14.4.2.2 Better function member
            // Otherwise, if one of MP and MQ is applicable in its non-expanded form (or has no params array) and the
            // other is applicable only in its expanded form (and has a params array),
            // then the non-expanded method is better.
            Assert.AreEqual("Foobar(int)", b.Foobar(0));

            // 14.4.2.2 Better function member
            // Otherwise, if the numbers of parameters K in MP and L in MQ are different,
            // then the method with more parameters is better.
            // This can only occur if both methods have params arrays
            // and are only applicable in their expanded forms.
            Assert.AreEqual("Foobar2(int, params)", b.Foobar2(0));
        }
コード例 #16
0
        public IFoo CreateFoo(Repo repo)
        {
            var foo = new FooBar();

            repo.Add(foo);
            return(foo);
        }
コード例 #17
0
 void InvokeFoobar()
 {
     FooFoo.Invoke(3);
     FooBar.Invoke(this, new MyEventArgs()
     {
         MyProperty = 3
     });
 }
コード例 #18
0
        public void ShouldReduceEventsToEntityInYourInitialStateWhenNotExistCommitedEvents()
        {
            var fooBar = new FooBar();

            var reduced = fooBar.GetState();

            reduced.Should().BeEquivalentTo(new FooBar());
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: ErgEnn/DynamicProxyTest
        static void Main(string[] args)
        {
            FooBar     fooBar   = new FooBar();
            MyContract contract = fooBar.GetImplementation <MyContract>();

            contract.PrintThis += (sender, s) => Console.WriteLine($"Print this: {s}");
            contract.PrintText("Peeter");
        }
コード例 #20
0
        public void ExtractAs_ReturnsValue_IfValueCanBeCastToExpectedType()
        {
            var fooBar  = new FooBar();
            var objects = new object[] { fooBar };

            var result = objects.ExtractAs <Foo>(0);

            Assert.AreEqual(fooBar, result);
        }
コード例 #21
0
ファイル: ThisFun.cs プロジェクト: sestoft/C5
    public static void Main()
    {
        var         fb   = new FooBar();
        IList <int> list = new LinkedList <int>();

        list.AddAll(new[] { 2, 3, 5, 7, 11 });
        list.Map <double>(fb).Apply(Console.WriteLine);
        list.Apply(fb);
    }
コード例 #22
0
ファイル: DynamicTest.cs プロジェクト: jsydenstricker/oneget
        public void TestInterfaceQuestion()
        {
            var  foobar = new FooBar();
            IOne iOne   = foobar;
            ITwo iTwo   = foobar;

            // Pity:
            // IOneAndTwo iBoth = foobar;
        }
コード例 #23
0
        public ActionResult KeyValueExample()
        {
            var key = Guid.NewGuid().ToString();

            _bucket.Insert(key, FooBar.Generate());
            var foobar = _bucket.Get <FooBar>(key).Value;

            ViewBag.Key = key;
            return(View(foobar));
        }
コード例 #24
0
 public void Bar(int[] xs, FooBar coolValues)
 {
     foreach (var someName in xs)
     {
       if (someName > 0)
       {
     coolValues.fe{caret}
       }
     }
 }
コード例 #25
0
        public void Case1()
        {
            var fooBar = new FooBar(1);

            var fooTask = Task.Run(() => fooBar.Foo(printFoo));

            var barTask = Task.Run(() => fooBar.Foo(printBar));

            Task.WaitAll(new Task[] { fooTask, barTask });
        }
コード例 #26
0
        public void ShouldReduceEventsToEntityByFilter()
        {
            var fooBar = new FooBar("bar", "foo");

            fooBar.RevertPropertyValues();

            var state = fooBar.PendingEvents.Reduce <FooBar>(@event => @event.Name.Equals("FAKE_CELEBRITY_WAS_UPDATED"));

            state.Foo.Should().Be("foo");
            state.Bar.Should().Be("bar");
        }
コード例 #27
0
    static void Main(string[] args)
    {
        var fooBar1 = new FooBar();

        Console.WriteLine(fooBar1.Baz);
        Console.WriteLine(fooBar1.Baz);
        var fooBar2 = new FooBar();

        Console.WriteLine(fooBar2.Baz);
        Console.WriteLine(fooBar2.Baz);
    }
コード例 #28
0
        public void Should_return_inut_value_When_not_a_mapping(int input)
        {
            //Given
            var foobar = new FooBar(Options.Create(new FooBarOptions()));

            //When
            var result = foobar.Compute(input);

            //Then
            Assert.Equal(input.ToString(), result);
        }
コード例 #29
0
        public void Should_return_bar_When_multiple_of_five()
        {
            //Given
            var foobar = new FooBar(Options.Create(new FooBarOptions()));

            //When
            var result = foobar.Compute(5);

            //Then
            Assert.Equal("bar", result);
        }
コード例 #30
0
        public void ShouldReduceEventsToEntityByCondition()
        {
            var fooBar = new FooBar("bar", "foo");

            fooBar.RevertPropertyValues();

            var state = fooBar.PendingEvents.Reduce <FooBar>();

            state.Foo.Should().Be("foo");
            state.Bar.Should().Be("bar");
        }
コード例 #31
0
        public async Task <IActionResult> Create(FooBar fooBar)
        {
            if (ModelState.IsValid)
            {
                _uow.FooBars.Add(fooBar);
                await _uow.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fooBar));
        }
コード例 #32
0
ファイル: MainPage.xaml.cs プロジェクト: addexm/cloudmine-wp7
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            var foo = new FooBar();
            foo.Id = this.Key.Text;
            foo.TextValue = "My type is: " + foo.CmType;
            foo.DateValue = DateTime.Now;

            foo.SaveAsync(result => {
                this.Results.Text = JsonConvert.SerializeObject(result);
            });
        }
コード例 #33
0
        public void ShouldAppendEventToPpenddingEventsQueueA()
        {
            var fooBar = new FooBar("bar", "foo");

            fooBar.RevertPropertyValues();

            var state = fooBar.PendingEvents.Reduce <FooBar>(@event => @event.Name.Equals("FAKE_CELEBRITY_WAS_CREATED"));

            state.Foo.Should().Be("bar");
            state.Bar.Should().Be("foo");
        }
コード例 #34
0
        public void ReturnsThisWhenProxyIsIncompatible() 
        {
		    FooBar obj = new FooBar();

		    AdvisedSupport advised = new AdvisedSupport();
            advised.Target = obj;
            advised.Interfaces = new Type[] { typeof(IFoo) };

            IFoo proxy = (IFoo)CreateProxy(advised);

            Assert.AreSame(obj, proxy.GetBarThis(),
                "Target should be returned when return types are incompatible");
		    Assert.AreSame(proxy, proxy.GetFooThis(),
                "Proxy should be returned when return types are compatible");
	    }
コード例 #35
0
        public void Analyze_SameInstanceRegisteredForTwoInterfacesUsingRegisterSingleton_DoesNotResultInAWarning()
        {
            var container = new Container();

            var fooBar = new FooBar();
            container.RegisterSingleton<IFoo>(fooBar);
            container.RegisterSingleton<IBar>(fooBar);

            container.Verify(VerificationOption.VerifyOnly);

            // Act
            var results = Analyzer.Analyze(container).OfType<TornLifestyleDiagnosticResult>();

            // Assert
            Assert.IsFalse(results.Any(), Actual(results));
        }
コード例 #36
0
ファイル: Program.cs プロジェクト: Stg3orge/Gundamnation
        static void Main(string[] args)
        {
            FooClass fooClass = new FooClass();
            fooClass.FooMethod();
            ((IFoo)fooClass).FooMethod();
            ((IBar)fooClass).FooMethod();
            BarClass barClass = new BarClass();
            barClass.FooMethod();
            ((IFoo)barClass).FooMethod();
            ((IBar)barClass).FooMethod();
            FooBar foobar = new FooBar();
            foobar.FooMethod();
            ((IFoo)foobar).FooMethod();
            ((IBar)foobar).FooMethod();

            System.Console.ReadKey();
        }
コード例 #37
0
  static void Main()
  {
    FooBar fooBar = new FooBar();

    Foo myBarFoo = new director_smartptr_MyBarFoo();
    check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()");
    check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()");
    check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()");

    Foo myFoo = myBarFoo.makeFoo();
    check(myFoo.pong(), "Foo::pong();Foo::ping()");
    check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()");
    check(myFoo.upcall(new FooBar()), "Bar::Foo2::Foo2Bar()");

    Foo myFoo2 = new Foo().makeFoo();
    check(myFoo2.pong(), "Foo::pong();Foo::ping()");
    check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
  }
        public void DoesPreserveDocumentIdCaseWhenPatchingFullCollection()
        {
            using (var store = NewDocumentStore(runInMemory:false))
            {
                string documentId = null;
                using (var session = store.OpenSession())
                {
                    var d = new FooBar() { };
                    session.Store(d);
                    session.SaveChanges();

                    documentId = session.Advanced.GetDocumentId(d);
                }

                using (var session = store.OpenSession())
                {
                    var d = session.Load<FooBar>(documentId);

                    //Demonstrates that RavenDb stores a case-sensitive document id somewhere
                    Assert.Equal(documentId, session.Advanced.GetDocumentId(d));
                }

                string script = @"  var id = __document_id; this.Name = id;";

                WaitForIndexing(store);

                string typeTag = store.Conventions.FindTypeTagName(typeof(FooBar));
                store
                    .DatabaseCommands
                    .UpdateByIndex(
                        "Raven/DocumentsByEntityName",
                        new IndexQuery() { Query = "Tag:" + typeTag },
                        new ScriptedPatchRequest() { Script = script },
                        null)
                    .WaitForCompletion();

                using (var session = store.OpenSession())
                {
                    var d = session.Load<FooBar>(documentId);
                    Assert.Equal("FooBars/1", d.Name);
                }
            }
        }
コード例 #39
0
ファイル: Program.cs プロジェクト: sclcwwl/Gimela
        public static void Serialize()
        {
            // Serialize (from Object to JsonString)
              var obj = new
              {
            Name = "Foo",
            Age = 30,
            Address = new
            {
              Country = "Japan",
              City = "Tokyo"
            },
            Like = new[] { "Microsoft", "Xbox" }
              };
              // {"Name":"Foo","Age":30,"Address":{"Country":"Japan","City":"Tokyo"},"Like":["Microsoft","Xbox"]}
              var jsonStringFromObj = DynamicJsonConvert.SerializeObject(obj);

              // [{"foo":"fooooo!","bar":1000},{"foo":"orz","bar":10}]
              var foobar = new FooBar[] {
            new FooBar { foo = "fooooo!", bar = 1000 },
            new FooBar { foo = "orz", bar = 10 } };
              var jsonFoobar = DynamicJsonConvert.SerializeObject(foobar);
        }
コード例 #40
0
 public void ClassTypeTest(FooBar data)
 {
 }
コード例 #41
0
ファイル: UnitTest1.cs プロジェクト: danielpalme/QuickInject
 public GuidString(string s, Mything f, FooBar ff)
 {
 }
 public virtual FooBarResult Any(FooBar fooBar)
 {
     _classWith2Methods.FooBar();
     return null;
 }
コード例 #43
0
 public override string upcall(FooBar fooBarPtr)
 {
   return "override;" + fooBarPtr.FooBarDo();
 }
コード例 #44
0
 public override string fooBar(FooBar fooBar)
 {
     return fooBar.FooBarDo();
 }
コード例 #45
0
ファイル: UnitTest.cs プロジェクト: davidebbo/ReflectionMagic
        public void TestFieldsAndProperties()
        {
            var fooBar = new FooBar();
            var properties = typeof(FooBar).GetProperties().Select(pi => pi.ToIProperty())
                                 .Union(
                             typeof(FooBar).GetFields().Select(fi => fi.ToIProperty()));

            foreach (var property in properties)
            {
                property.SetValue(fooBar, "test", null);
                Assert.Equal(property.PropertyType, typeof(string));
            }

            Assert.Equal(fooBar._field, "test");
            Assert.Equal(fooBar.Property, "test");
        }
コード例 #46
0
ファイル: ContextStackTests.cs プロジェクト: Corillian/corefx
        [Fact] // Item (Type)
        public void Indexer2()
        {
            ContextStack stack = new ContextStack();

            Foo foo = new Foo();
            FooBar foobar = new FooBar();

            stack.Push(foobar);
            stack.Push(foo);
            Assert.Same(foo, stack[typeof(Foo)]);
            Assert.Same(foo, stack[typeof(IFoo)]);
            Assert.Same(foo, stack.Pop());
            Assert.Same(foobar, stack[typeof(Foo)]);
            Assert.Same(foobar, stack[typeof(FooBar)]);
            Assert.Same(foobar, stack[typeof(IFoo)]);
            Assert.Null(stack[typeof(string)]);
        }
コード例 #47
0
ファイル: ContextStackTest.cs プロジェクト: nlhepler/mono
		[Test] // Item (Type)
		public void Indexer2 ()
		{
			ContextStack stack = new ContextStack ();

			Foo foo = new Foo ();
			FooBar foobar = new FooBar ();

			stack.Push (foobar);
			stack.Push (foo);
			Assert.AreSame (foo, stack [typeof (Foo)], "#1");
			Assert.AreSame (foo, stack [typeof (IFoo)], "#2");
			Assert.AreSame (foo, stack.Pop (), "#3");
			Assert.AreSame (foobar, stack [typeof (Foo)], "#4");
			Assert.AreSame (foobar, stack [typeof (FooBar)], "#5");
			Assert.AreSame (foobar, stack [typeof (IFoo)], "#6");
			Assert.IsNull (stack [typeof (string)], "#7");
		}