コード例 #1
0
 public void LoadDocTypesTest_DatePropertyMapping()
 {
     DocTypeObjectBuilder target = new DocTypeObjectBuilder(string.Empty);
     var dateReader = Isolate.Fake.Instance<IRecordsReader>();
     Isolate.WhenCalled(() => dateReader.GetDbType()).WillReturn("Date");
     var dateProp = target.BuildProperty(dateReader);
     Assert.AreEqual(typeof(DateTime), dateProp.DatabaseType);
 }
コード例 #2
0
        public void LoadDocTypesTest_DocTypeProperties()
        {
            ISqlHelper fakeSql = Isolate.Fake.Instance<ISqlHelper>(Members.ReturnRecursiveFakes);

            IRecordsReader fakeReader = Isolate.Fake.Instance<IRecordsReader>();

            var dtGuid = Guid.NewGuid();

            //get the data for the DT
            Isolate.WhenCalled(() => fakeReader.HasRecords).WillReturn(true);
            Isolate.WhenCalled(() => fakeReader.Read()).WillReturn(true);
            Isolate.WhenCalled(() => fakeSql.ExecuteReader(string.Empty)).WillReturn(fakeReader);
            Isolate.WhenCalled(() => fakeReader.GetId()).WillReturn(0);
            Isolate.WhenCalled(() => fakeReader.Read()).WillReturnRepeat(true, 4).AndThen().CallOriginal();
            Isolate.WhenCalled(() => fakeReader.GetParentId()).WillReturn(-1);

            Isolate.WhenCalled(() => fakeReader.GetAlias()).WillReturn("Property1 Alias");
            Isolate.WhenCalled(() => fakeReader.GetString("RegularExpression")).WillReturn(string.Empty);
            Isolate.WhenCalled(() => fakeReader.GetDbType()).WillReturn("Integer");
            Isolate.WhenCalled(() => fakeReader.GetDescription()).WillReturn("Property1 Description");
            Isolate.WhenCalled(() => fakeReader.GetId()).WillReturn(1);
            Isolate.WhenCalled(() => fakeReader.GetName()).WillReturn("Property1");

            Isolate.WhenCalled(() => fakeReader.GetString("RegularExpression")).WillReturn(string.Empty);
            Isolate.WhenCalled(() => fakeReader.GetDbType()).WillReturn("Ntext");

            Isolate.WhenCalled(() => fakeReader.GetString("RegularExpression")).WillReturn(string.Empty);
            Isolate.WhenCalled(() => fakeReader.GetDbType()).WillReturn("Nvarchar");

            Isolate.WhenCalled(() => fakeReader.GetString("RegularExpression")).WillReturn(string.Empty);
            Isolate.WhenCalled(() => fakeReader.GetDbType()).WillReturn("Date");

            DocTypeObjectBuilder target = new DocTypeObjectBuilder(string.Empty);
            Isolate.WhenCalled(() => target.SqlHelper).WillReturn(fakeSql);
            target.LoadDocTypes();

            Isolate.Verify.WasCalledWithExactArguments(() => target.GetProperties(0));
            Isolate.Verify.WasCalledWithExactArguments(() => target.BuildProperty(fakeReader));

            Isolate.Verify.WasCalledWithAnyArguments(() => fakeSql.ExecuteReader(string.Empty));
            Isolate.Verify.WasCalledWithExactArguments(() => fakeReader.GetAlias());
            Isolate.Verify.WasCalledWithExactArguments(() => fakeReader.GetDbType());
            Isolate.Verify.WasCalledWithExactArguments(() => fakeReader.GetDescription());
            Isolate.Verify.WasCalledWithExactArguments(() => fakeReader.GetName());
            Isolate.Verify.WasCalledWithExactArguments(() => fakeReader.GetString("RegularExpression"));
            Isolate.Verify.WasCalledWithExactArguments(() => fakeReader.GetId());

            var dt = target.DocumentTypes[0];

            Assert.IsNotNull(dt.Properties);
            Assert.AreEqual(4, dt.Properties.Count);

            Assert.AreEqual("Property1 Alias", dt.Properties[0].Alias);
            Assert.AreEqual(typeof(int), dt.Properties[0].DatabaseType);
            Assert.AreEqual("Property1 Description", dt.Properties[0].Description);
            Assert.AreEqual(1, dt.Properties[0].Id);
            Assert.AreEqual(false, dt.Properties[0].Mandatory);
            Assert.AreEqual("Property1", dt.Properties[0].Name);
            Assert.AreEqual(string.Empty, dt.Properties[0].RegularExpression);
            Assert.AreEqual(typeof(string), dt.Properties[1].DatabaseType);
            Assert.AreEqual(typeof(string), dt.Properties[2].DatabaseType);
            Assert.AreEqual(typeof(DateTime), dt.Properties[3].DatabaseType);

        }
コード例 #3
0
 public void LoadDocTypesTest_ObjectPropertyMapping()
 {
     DocTypeObjectBuilder target = new DocTypeObjectBuilder(string.Empty);
     var objReader = Isolate.Fake.Instance<IRecordsReader>();
     Isolate.WhenCalled(() => objReader.GetDbType()).WillReturn("Something undefined");
     var objProp = target.BuildProperty(objReader);
     Assert.AreEqual(typeof(object), objProp.DatabaseType);
 }