Пример #1
0
		deco CreateDeco()
		{
			// Need a rounded date as DB can't store millis
			var now = DateTime.UtcNow;
			now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

			// Setup a record
			var o = new deco();
			o.title = string.Format("insert {0}", r.Next());
			o.draft = true;
			o.content = string.Format("insert {0}", r.Next());
			o.date_created = now;
			o.date_edited = now;
			o.state = State.Maybe;
			o.col_w_space = 23;
			o.nullreal = 24;

			return o;
		}
Пример #2
0
        public async Task DateTimeNullable()
        {
            // Need a rounded date as DB can't store millis
            var now = DateTime.UtcNow;

            now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

            // Setup a record
            var a = new deco();

            a.title        = string.Format("insert {0}", r.Next());
            a.draft        = true;
            a.content      = string.Format("insert {0}", r.Next());
            a.date_created = now;
            a.date_edited  = null;

            await db.InsertAsync(a);

            // Retrieve it
            var b = await db.SingleOrDefaultAsync <deco>("WHERE id=@0", a.id);

            Assert.AreEqual(b.id, a.id);
            Assert.AreEqual(b.date_edited.HasValue, false);

            // Update it to NULL
            b.date_edited = now;
            await db.UpdateAsync(b);

            var c = await db.SingleOrDefaultAsync <deco>("WHERE id=@0", a.id);

            Assert.AreEqual(c.id, a.id);
            Assert.AreEqual(c.date_edited.HasValue, true);

            // Update it to not NULL
            c.date_edited = null;
            await db.UpdateAsync(c);

            var d = await db.SingleOrDefaultAsync <deco>("WHERE id=@0", a.id);

            Assert.AreEqual(d.id, a.id);
            Assert.AreEqual(d.date_edited.HasValue, false);
        }
Пример #3
0
        deco CreateDeco()
        {
            // Need a rounded date as DB can't store millis
            var now = DateTime.UtcNow;

            now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

            // Setup a record
            var o = new deco();

            o.title        = string.Format("insert {0}", r.Next());
            o.draft        = true;
            o.content      = string.Format("insert {0}", r.Next());
            o.date_created = now;
            o.date_edited  = now;
            o.state        = State.Maybe;
            o.col_w_space  = 23;
            o.nullreal     = 24;

            return(o);
        }
Пример #4
0
		public async Task DateTimeNullable()
		{
			// Need a rounded date as DB can't store millis
			var now = DateTime.UtcNow;
			now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

			// Setup a record
			var a = new deco();
			a.title = string.Format("insert {0}", r.Next());
			a.draft = true;
			a.content = string.Format("insert {0}", r.Next());
			a.date_created = now;
			a.date_edited = null;

			await db.InsertAsync(a);

			// Retrieve it
			var b = await db.SingleOrDefaultAsync<deco>("WHERE id=@0", a.id);
			Assert.AreEqual(b.id, a.id);
			Assert.AreEqual(b.date_edited.HasValue, false);

			// Update it to NULL
			b.date_edited = now;
			await db.UpdateAsync(b);
			var c = await db.SingleOrDefaultAsync<deco>("WHERE id=@0", a.id);
			Assert.AreEqual(c.id, a.id);
			Assert.AreEqual(c.date_edited.HasValue, true);

			// Update it to not NULL
			c.date_edited = null;
			await db.UpdateAsync(c);
			var d = await db.SingleOrDefaultAsync<deco>("WHERE id=@0", a.id);
			Assert.AreEqual(d.id, a.id);
			Assert.AreEqual(d.date_edited.HasValue, false);
		}
Пример #5
0
		void AssertPocos(deco a, deco b)
		{
			Assert.AreEqual(a.id, b.id);
			Assert.AreEqual(a.title, b.title);
			Assert.AreEqual(a.draft, b.draft);
			Assert.AreEqual(a.content, b.content);
			Assert.AreEqual(a.date_created, b.date_created);
			Assert.AreEqual(a.state, b.state);
			Assert.AreEqual(a.state2, b.state2);
			Assert.AreEqual(a.col_w_space, b.col_w_space);
			Assert.AreEqual(a.nullreal, b.nullreal);
		}