Exemplo n.º 1
0
        public void WriteNoAttributes()
        {
            var expected = new TestWriteClass
            {
                Int         = 23,
                PropInt     = 32,
                NullInt     = 22,
                PropNullInt = 33,
                String      = "testing 123",
                PropString  = "testing yet again",
                Char        = 'a',
                PropChar    = 'b',
                //NullChar = 'c',
                //PropNullChar = 'd',
                Dt         = DateTime.UtcNow.AddDays(-31),
                PropDt     = DateTime.UtcNow.AddYears(-2).AddDays(-7),
                NullDt     = DateTime.UtcNow.AddDays(-31),
                PropNullDt = DateTime.UtcNow.AddHours(-22),
                Bl         = true,
                PropBl     = true,
                PropNullBl = true,
                NullBl     = true
            };

            IndexManager.Of(Index).Write(new List <TestWriteClass> {
                expected
            });

            var query  = new TermQuery(new Term("Int", expected.Int.ToString()));
            var actual = IndexManager.Of(Index).Query <TestWriteClass>(query, 1).Results.SingleOrDefault();

            Assert.IsNotNull(actual, "Returns only one object");

            Assert.AreEqual(actual.Int, expected.Int);
            Assert.AreEqual(actual.PropInt, expected.PropInt);
            Assert.AreEqual(actual.NullInt.GetValueOrDefault(), expected.NullInt.GetValueOrDefault());
            Assert.AreEqual(actual.PropNullInt.GetValueOrDefault(), expected.PropNullInt.GetValueOrDefault());
            Assert.AreEqual(actual.NullInt.HasValue, expected.NullInt.HasValue);
            Assert.AreEqual(actual.PropNullInt.HasValue, expected.PropNullInt.HasValue);
            Assert.AreEqual(actual.PropString, expected.PropString);
            Assert.AreEqual(actual.String, expected.String);

            Assert.AreEqual(actual.NullDt.HasValue, expected.NullDt.HasValue);
            Assert.AreEqual(actual.PropNullDt.HasValue, expected.PropNullDt.HasValue);

            Assert.AreEqual(actual.PropNullDt.Value.Day, expected.PropNullDt.Value.Day);
        }
Exemplo n.º 2
0
        public void WriteNoAttributes()
        {
            var expected = new TestWriteClass
                {
                    Int = 23,
                    PropInt = 32,
                    NullInt = 22,
                    PropNullInt = 33,
                    String = "testing 123",
                    PropString = "testing yet again",
                    Char = 'a',
                    PropChar = 'b',
                    //NullChar = 'c',
                    //PropNullChar = 'd',
                    Dt = DateTime.UtcNow.AddDays(-31),
                    PropDt = DateTime.UtcNow.AddYears(-2).AddDays(-7),
                    NullDt = DateTime.UtcNow.AddDays(-31),
                    PropNullDt = DateTime.UtcNow.AddHours(-22),
                    Bl = true,
                    PropBl = true,
                    PropNullBl = true,
                    NullBl = true
                };

            IndexManager.Of(Index).Write(new List<TestWriteClass>{expected});

            var query = new TermQuery(new Term("Int", expected.Int.ToString()));
            var actual = IndexManager.Of(Index).Query<TestWriteClass>(query, 1).SingleOrDefault();

            Assert.IsNotNull(actual, "Returns only one object");

            Assert.AreEqual(actual.Int, expected.Int);
            Assert.AreEqual(actual.PropInt, expected.PropInt);
            Assert.AreEqual(actual.NullInt.GetValueOrDefault(), expected.NullInt.GetValueOrDefault());
            Assert.AreEqual(actual.PropNullInt.GetValueOrDefault(), expected.PropNullInt.GetValueOrDefault());
            Assert.AreEqual(actual.NullInt.HasValue, expected.NullInt.HasValue);
            Assert.AreEqual(actual.PropNullInt.HasValue, expected.PropNullInt.HasValue);
            Assert.AreEqual(actual.PropString, expected.PropString);
            Assert.AreEqual(actual.String, expected.String);

            Assert.AreEqual(actual.NullDt.HasValue, expected.NullDt.HasValue);
            Assert.AreEqual(actual.PropNullDt.HasValue, expected.PropNullDt.HasValue);

            Assert.AreEqual(actual.PropNullDt.Value.Day, expected.PropNullDt.Value.Day);
        }