Exemple #1
0
        public void DateTime_Test()
        {
            using (ObjectExtensions.ConfigScope(new N4pper.ObjectExtensionsConfiguration()))
            {
                DateTime now = DateTime.Now;
                now = now.AddTicks(-(now.Ticks % TimeSpan.FromMilliseconds(1).Ticks));
                TestDateTime test = new TestDateTime()
                {
                    Value = 1, ValueString = "test", ValueDate = now, ValueDateOff = now, ValueDateNull = now, ValueDateOffNull = now
                };

                var props = test.ToPropDictionary();

                props["ValueDate"]        = ((DateTimeOffset)now).ToUnixTimeMilliseconds();
                props["ValueDateOff"]     = ((DateTimeOffset)now).ToUnixTimeMilliseconds();
                props["ValueDateNull"]    = ((DateTimeOffset)now).ToUnixTimeMilliseconds();
                props["ValueDateOffNull"] = ((DateTimeOffset)now).ToUnixTimeMilliseconds();

                test = test.CopyProperties(props);

                Assert.Equal(now, test.ValueDate);
                Assert.Equal(now, test.ValueDateOff);
                Assert.Equal(now, test.ValueDateNull);
                Assert.Equal(now, test.ValueDateOffNull);
            }
        }
Exemple #2
0
        public IDisposable ScopeOMnG()
        {
            IDisposable obj = ObjectExtensions.ConfigScope(ObjectExtensionsConfiguration);
            IDisposable tpy = TypeExtensions.ConfigScope(TypeExtensionsConfiguration);

            return(new CustomDisposable(() =>
            {
                obj?.Dispose();
                tpy?.Dispose();
            }));
        }
        public void CopyProperties2()
        {
            TestEveryType tnode = new TestEveryType()
            {
                Id = 1
            };

            PrepareEntity(tnode);

            using (ObjectExtensions.ConfigScope(new ObjectExtensionsConfiguration.DelegateILCachingConfiguration()))
            {
                CheckEquals(tnode);
            }
            using (ObjectExtensions.ConfigScope(new ObjectExtensionsConfiguration.DelegateCachingConfiguration()))
            {
                CheckEquals(tnode);
            }
        }
Exemple #4
0
        public void TimeSpan_Test()
        {
            using (ObjectExtensions.ConfigScope(new N4pper.ObjectExtensionsConfiguration()))
            {
                TestTimeSpan test = new TestTimeSpan()
                {
                    TimeSpan = TimeSpan.FromMilliseconds(1234), TimeSpanNull = TimeSpan.FromMilliseconds(1234)
                };

                var props = test.ToPropDictionary();

                props["TimeSpan"]     = 1234;
                props["TimeSpanNull"] = 1234;

                test = test.CopyProperties(props);

                Assert.Equal(TimeSpan.FromMilliseconds(1234), test.TimeSpan);
                Assert.Equal(TimeSpan.FromMilliseconds(1234), test.TimeSpanNull);
            }
        }