Ejemplo n.º 1
0
        public void Builder_OmitRequired()
        {
            SimpleRecord s;

            SimpleRecordBuilder b = new SimpleRecordBuilder();

            b.intValue        = 5;
            b.anotherIntValue = 6;

            s = b.Build();
        }
Ejemplo n.º 2
0
        public void Builder_Defaults()
        {
            SimpleRecord s;

            SimpleRecordBuilder b = new SimpleRecordBuilder();

            b.stringField = "hello";

            s = b.Build();

            Assert.AreEqual("hello", s.stringField);
            Assert.AreEqual(1, s.intValue);
            Assert.AreEqual(2, s.anotherIntValue);
            Assert.IsTrue(s.hasStringField);
            Assert.IsFalse(s.hasIntValue);
            Assert.IsFalse(s.hasAnotherIntValue);
        }
Ejemplo n.º 3
0
        public void Builder()
        {
            SimpleRecord s;

            SimpleRecordBuilder b = new SimpleRecordBuilder();

            b.stringField     = "hello";
            b.intValue        = 5;
            b.anotherIntValue = 6;

            s = b.Build();

            Assert.AreEqual("hello", s.stringField);
            Assert.AreEqual(5, s.intValue);
            Assert.AreEqual(6, s.anotherIntValue);
            Assert.IsTrue(s.hasStringField);
            Assert.IsTrue(s.hasIntValue);
            Assert.IsTrue(s.hasAnotherIntValue);
        }
Ejemplo n.º 4
0
        public void FullCycle()
        {
            SimpleRecord s;

            SimpleRecordBuilder b = new SimpleRecordBuilder();

            b.stringField     = "hello";
            b.intValue        = 5;
            b.anotherIntValue = 6;

            s = b.Build();

            Dictionary <string, object> dataMap = s.Data();

            SimpleRecord reclaimed = new SimpleRecord(dataMap);

            Assert.AreNotSame(s, reclaimed);
            Assert.AreEqual(s.stringField, reclaimed.stringField);
            Assert.AreEqual(s.intValue, reclaimed.intValue);
            Assert.AreEqual(s.anotherIntValue, reclaimed.anotherIntValue);
        }