コード例 #1
0
        public static void TestSet_Throws_Called()
        {
            var f1 = new Foo(0, "0");
            var f2 = new Foo(1, "1");

            // Throw OnValidate
            var collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f1);
            collBase.OnValidateThrow = true;

            Assert.Throws<Exception>(() => collBase[0] = f2);
            Assert.Equal(f1, collBase[0]);

            // Throw OnSet
            collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f1);
            collBase.OnSetThrow = true;

            Assert.Throws<Exception>(() => collBase[0] = f2);
            Assert.Equal(f1, collBase[0]);

            // Throw OnSetComplete
            collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f1);
            collBase.OnSetCompleteThrow = true;

            Assert.Throws<Exception>(() => collBase[0] = f2);
            Assert.Equal(f1, collBase[0]);
        }
コード例 #2
0
        public static void TestClear_Throws_Called()
        {
            var f = new Foo(0, "0");

            // Throw OnValidate
            var collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f);
            collBase.OnValidateThrow = true;

            collBase.Clear();
            Assert.Equal(0, collBase.Count);

            // Throw OnClear
            collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f);
            collBase.OnClearThrow = true;

            Assert.Throws<Exception>(() => collBase.Clear());
            Assert.Equal(1, collBase.Count);

            // Throw OnClearComplete
            collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f);
            collBase.OnClearCompleteThrow = true;

            Assert.Throws<Exception>(() => collBase.Clear());
            Assert.Equal(0, collBase.Count);
        }
コード例 #3
0
        public static void TestSet_Called()
        {
            var f = new Foo(1, "1");

            var collBase = new OnMethodCalledCollectionBase();
            collBase.Add(new Foo());
            collBase.OnValidateCalled = false;

            collBase[0] = f;

            Assert.True(collBase.OnValidateCalled);
            Assert.True(collBase.OnSetCalled);
            Assert.True(collBase.OnSetCompleteCalled);

            Assert.Equal(f, collBase[0]);
        }
コード例 #4
0
        public static void TestClear_Called()
        {
            var f = new Foo(0, "0");
            var collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f);
            collBase.Clear();

            Assert.True(collBase.OnClearCalled);
            Assert.True(collBase.OnClearCompleteCalled);

            Assert.Equal(0, collBase.Count);
        }
コード例 #5
0
        public static void TestRemoveAt_Called()
        {
            var f = new Foo(0, "0");
            var collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f);
            collBase.OnValidateCalled = false;

            collBase.RemoveAt(0);

            Assert.True(collBase.OnValidateCalled);
            Assert.True(collBase.OnRemoveCalled);
            Assert.True(collBase.OnRemoveCompleteCalled);

            Assert.False(collBase.Contains(f));
        }
コード例 #6
0
        public static void TestInsert_Throws_Called()
        {
            var f = new Foo(0, "0");

            // Throw OnValidate
            var collBase = new OnMethodCalledCollectionBase();
            collBase.OnValidateThrow = true;

            Assert.Throws<Exception>(() => collBase.Insert(0, f));
            Assert.Equal(0, collBase.Count);

            // Throw OnInsert
            collBase = new OnMethodCalledCollectionBase();
            collBase.OnInsertThrow = true;

            Assert.Throws<Exception>(() => collBase.Insert(0, f));
            Assert.Equal(0, collBase.Count);

            // Throw OnInsertComplete
            collBase = new OnMethodCalledCollectionBase();
            collBase.OnInsertCompleteThrow = true;

            Assert.Throws<Exception>(() => collBase.Insert(0, f));
            Assert.Equal(0, collBase.Count);
        }
コード例 #7
0
        public static void TestInsert_Called()
        {
            var f = new Foo(0, "0");
            var collBase = new OnMethodCalledCollectionBase();

            collBase.Insert(0, f);
            Assert.True(collBase.OnValidateCalled);
            Assert.True(collBase.OnInsertCalled);
            Assert.True(collBase.OnInsertCompleteCalled);

            Assert.True(collBase.Contains(f));
        }
コード例 #8
0
ファイル: CollectionBaseTests.cs プロジェクト: ESgarbi/corefx
        public static void RemoveAt_Throws_Called()
        {
            var f = new Foo(0, "0");

            // Throw OnValidate
            var collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f);
            collBase.OnValidateThrow = true;

            Assert.Throws<Exception>(() => collBase.RemoveAt(0));
            Assert.Equal(1, collBase.Count);

            // Throw OnRemove
            collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f);
            collBase.OnRemoveThrow = true;

            Assert.Throws<Exception>(() => collBase.RemoveAt(0));
            Assert.Equal(1, collBase.Count);

            // Throw OnRemoveComplete
            collBase = new OnMethodCalledCollectionBase();
            collBase.Add(f);
            collBase.OnRemoveCompleteThrow = true;

            Assert.Throws<Exception>(() => collBase.RemoveAt(0));
            Assert.Equal(1, collBase.Count);
        }