Beispiel #1
0
        public void XmlPersistenceTest()
        {
            var context = new NumbersPowersContext();

            for (int i = 0; i < 10; i++)
            {
                var number = new Number {
                    Value = i, XReps = new string('x', i)
                };
                context.Numbers.Rows.Add(number);

                for (int j = 0; j < 10; j++)
                {
                    context.Powers.Rows.Add(new PowersRow {
                        Base = number, Exponent = j
                    });
                }
            }

            var newContext = new NumbersPowersContext();

            newContext.ReadXml(context.ToXml());

            Assert.AreEqual(10, newContext.Numbers.Rows.Count);
            Assert.AreEqual(100, newContext.Powers.Rows.Count);
        }
Beispiel #2
0
        public void RelatedTypedRowsTest()
        {
            var context = new NumbersPowersContext();

            for (int i = 0; i < 10; i++)
            {
                var number = new Number {
                    Value = i, XReps = new string('x', i)
                };
                context.Numbers.Rows.Add(number);

                if (i % 3 == 0)
                {
                    var children = number.Powers;

                    int rowCount = 0;
                    children.RowAdded += (s, e) => {
                        Assert.AreEqual(e.Row, children.Last());
                        rowCount++;
                        Assert.AreEqual(rowCount, children.Count);
                    };
                    children.RowRemoved += (s, e) => {
                        Assert.IsFalse(children.Contains(e.Row));
                        rowCount--;
                        Assert.AreEqual(rowCount, children.Count);
                    };
                }

                for (int j = 0; j < 11; j++)
                {
                    context.Powers.Rows.Add(new PowersRow {
                        Base = number, Exponent = j
                    });
                }
                context.Powers.Rows.Remove(context.Powers.Rows.Last());
                number.Powers.Last().RemoveRow();

                context.Powers.Rows.AddFromValues(number, 9);
                Assert.AreEqual(10, number.Powers.Count);
            }
            Assert.AreEqual(10, context.Numbers.Rows.Count);
            Assert.AreEqual(100, context.Powers.Rows.Count);

            context.Powers.Rows.Clear();
            Assert.AreEqual(0, context.Powers.Rows.Count);
            Assert.AreEqual(0, context.Numbers.Rows[0].Powers.Count);

            context.Powers.Rows.AddFromValues(context.Numbers.Rows[0], 4);
            Assert.AreEqual(1, context.Numbers.Rows[0].Powers.Count);
        }
		public void XmlPersistenceTest() {
			var context = new NumbersPowersContext();

			for (int i = 0; i < 10; i++) {
				var number = new Number { Value = i, XReps = new string('x', i) };
				context.Numbers.Rows.Add(number);

				for (int j = 0; j < 10; j++) {
					context.Powers.Rows.Add(new PowersRow { Base = number, Exponent = j });
				}
			}

			var newContext = new NumbersPowersContext();
			newContext.ReadXml(context.ToXml());

			Assert.AreEqual(10, newContext.Numbers.Rows.Count);
			Assert.AreEqual(100, newContext.Powers.Rows.Count);
		}
		public void RelatedTypedRowsTest() {
			var context = new NumbersPowersContext();

			for (int i = 0; i < 10; i++) {
				var number = new Number { Value = i, XReps = new string('x', i) };
				context.Numbers.Rows.Add(number);

				if (i % 3 == 0) {
					var children = number.Powers;

					int rowCount = 0;
					children.RowAdded += (s, e) => {
						Assert.AreEqual(e.Row, children.Last());
						rowCount++;
						Assert.AreEqual(rowCount, children.Count);
					};
					children.RowRemoved += (s, e) => {
						Assert.IsFalse(children.Contains(e.Row));
						rowCount--;
						Assert.AreEqual(rowCount, children.Count);
					};
				}

				for (int j = 0; j < 11; j++) {
					context.Powers.Rows.Add(new PowersRow { Base = number, Exponent = j });
				}
				context.Powers.Rows.Remove(context.Powers.Rows.Last());
				number.Powers.Last().RemoveRow();

				context.Powers.Rows.AddFromValues(number, 9);
				Assert.AreEqual(10, number.Powers.Count);
			}
			Assert.AreEqual(10, context.Numbers.Rows.Count);
			Assert.AreEqual(100, context.Powers.Rows.Count);

			context.Powers.Rows.Clear();
			Assert.AreEqual(0, context.Powers.Rows.Count);
			Assert.AreEqual(0, context.Numbers.Rows[0].Powers.Count);

			context.Powers.Rows.AddFromValues(context.Numbers.Rows[0], 4);
			Assert.AreEqual(1, context.Numbers.Rows[0].Powers.Count);
		}
		public void TypedTableAccessorTest() {
			var context = new NumbersPowersContext();
			Assert.AreEqual(context.Powers, context.Table<PowersRow>());
		}
Beispiel #6
0
        public void TypedTableAccessorTest()
        {
            var context = new NumbersPowersContext();

            Assert.AreEqual(context.Powers, context.Table <PowersRow>());
        }