Esempio n. 1
0
        public void Ensure_we_can_match_on_properties_ignoring_nulls()
        {
            var item = new TableWithAutoIncrementPrimaryKey {
                Name = "Michale", SomeNumber = 33
            };
            var testTableItems = new[]
            {
                new TableWithAutoIncrementPrimaryKey {
                    Name = "Michale", SomeNumber = 31
                },
                item,
                new TableWithAutoIncrementPrimaryKey {
                    Name = "Michael", SomeNumber = 33
                },
                new TableWithAutoIncrementPrimaryKey {
                    Name = "Michale", SomeNumber = null
                },
                new TableWithAutoIncrementPrimaryKey {
                    Name = null, SomeNumber = 33
                }
            };

            DataBaseScriptRunnerAndBuilder.InsertTableWithAutoGeneratedPrimaryKey(Connection, testTableItems);
            var oldNumber = item.SomeNumber;

            item.SomeNumber = null;
            var results = Sut.GetExactMatches(item, true);

            Assert.AreEqual(3, results.Count());
            Assert.AreEqual(3, results.Count(t => t.Name == item.Name));
            Assert.AreEqual(1, results.Count(t => t.SomeNumber == oldNumber));
            Assert.AreEqual(1, results.Count(t => t.SomeNumber is null));
        }
Esempio n. 2
0
        public void Ensure_we_can_match_on_properties_withNull()
        {
            var item = new TableWithAutoIncrementPrimaryKey {
                Name = "Michale", SomeNumber = null
            };
            var testTableItems = new[]
            {
                new TableWithAutoIncrementPrimaryKey {
                    Name = "Michale", SomeNumber = 31
                },
                item,
                new TableWithAutoIncrementPrimaryKey {
                    Name = "Michael", SomeNumber = 33
                },
                new TableWithAutoIncrementPrimaryKey {
                    Name = null, SomeNumber = 33
                }
            };

            DataBaseScriptRunnerAndBuilder.InsertTableWithAutoGeneratedPrimaryKey(Connection, testTableItems);

            var results = Sut.GetExactMatches(item, false);

            Assert.AreEqual(1, results.Count());
            var test = results.First();

            Assert.IsNotNull(test);
            Assert.AreEqual(item.Name, test.Name);
            Assert.AreEqual(item.SomeNumber, test.SomeNumber);
        }
Esempio n. 3
0
        public async Task Ensure_we_Can_Get_correct_record_Back_when_id_is_a_number_diff_name()
        {
            var testTableItems = new[]
            {
                new TableWithAutoIncrementPrimaryKey {
                    Name = "Michale", SomeNumber = 33
                },
            };

            DataBaseScriptRunnerAndBuilder.InsertTableWithAutoGeneratedPrimaryKey(Connection, testTableItems);
            var record = DataBaseScriptRunnerAndBuilder.GetAll <TableWithAutoIncrementPrimaryKey>(Connection).First();


            var item = await Sut.GetById(new TableWithAutoIncrementPrimaryKeyDiffSqlName { Id = record.Id });

            Assert.IsNotNull(item);
            Assert.AreEqual(record.Id, item.Id);
            Assert.AreEqual(testTableItems.First().SomeNumber, item.SomeNumber);
            Assert.AreEqual(testTableItems.First().Name, item.Name);
        }