Ejemplo n.º 1
0
        public void SerializeDateNullValue()
        {
            var now = DateTimeOffset.UtcNow;

            var expectedSerializedString = "{\"nullableDate\":null}";

            var recurrence = new DateTestClass();

            var serializedString = this.serializer.SerializeObject(recurrence);

            Assert.Equal(expectedSerializedString, serializedString);
        }
Ejemplo n.º 2
0
        public void SerializeDateNullValue()
        {
            var now = DateTimeOffset.UtcNow;

            var expectedSerializedString = "{}";

            var recurrence = new DateTestClass();

            var serializedString = this.serializer.SerializeObject(recurrence);

            Assert.AreEqual(expectedSerializedString, serializedString, "Unexpected value serialized.");
        }
Ejemplo n.º 3
0
        public void SerializeInvalidTypeForDateConverter()
        {
            var dateToSerialize = new DateTestClass
            {
                InvalidType = 1,
            };

            ServiceException serviceException = Assert.Throws <ServiceException>(() => this.serializer.SerializeObject(dateToSerialize));

            Assert.True(serviceException.IsMatch(ErrorConstants.Codes.GeneralException));
            Assert.Equal(
                ErrorConstants.Messages.InvalidTypeForDateConverter,
                serviceException.Error.Message);
        }
Ejemplo n.º 4
0
        public void SerializeDateValue()
        {
            var now = DateTimeOffset.UtcNow;

            var expectedSerializedString = string.Format("{{\"nullableDate\":\"{0}\"}}", now.ToString("yyyy-MM-dd"));

            var date = new DateTestClass
            {
                NullableDate = new Date(now.Year, now.Month, now.Day),
            };

            var serializedString = this.serializer.SerializeObject(date);

            Assert.Equal(expectedSerializedString, serializedString);
        }
Ejemplo n.º 5
0
        public void SerializeDateEnumerableValue()
        {
            var now      = DateTimeOffset.UtcNow;
            var tomorrow = now.AddDays(1);

            var expectedSerializedString = string.Format("{{\"nullableDate\":null,\"dateCollection\":[\"{0}\",\"{1}\"]}}", now.ToString("yyyy-MM-dd"), tomorrow.ToString("yyyy-MM-dd"));

            var recurrence = new DateTestClass
            {
                DateCollection = new List <Date> {
                    new Date(now.Year, now.Month, now.Day), new Date(tomorrow.Year, tomorrow.Month, tomorrow.Day)
                },
            };

            var serializedString = this.serializer.SerializeObject(recurrence);

            Assert.Equal(expectedSerializedString, serializedString);
        }
Ejemplo n.º 6
0
        public void TestCreated()
        {
            var pm = PmFactory.NewPersistenceManager();

            // dt = new DateTime(2004, 10, 12, 13, 30, 31, 123);
            DateTestClass dtc = new DateTestClass();
            InnerDate     id  = new InnerDate();

            id.SetInnerDate();
            pm.MakePersistent(id);
            pm.MakePersistent(dtc);
            pm.Save();
            dtc.InnerDate = id;
            dtc.Name      = "Test";
            pm.Save();
            pm.UnloadCache();

            NDOQuery <DateTestClass> q = new NDOQuery <DateTestClass>(pm, null);

            dtc = (DateTestClass)q.ExecuteSingle(true);
            Assert.AreEqual(2002, dtc.InnerDate.Dt.Year, "DateTime konnte nicht richtig gelesen werden");
        }
        public void SerializeInvalidTypeForDateConverter()
        {
            var dateToSerialize = new DateTestClass
            {
                InvalidType = 1,
            };

            try
            {
                var serializedString = this.serializer.SerializeObject(dateToSerialize);
            }
            catch (ServiceException serviceException)
            {
                Assert.IsTrue(serviceException.IsMatch(ErrorConstants.Codes.GeneralException), "Unexpected error code thrown.");
                Assert.AreEqual(
                    ErrorConstants.Messages.InvalidTypeForDateConverter,
                    serviceException.Error.Message,
                    "Unexpected error message thrown.");

                throw;
            }
        }