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));
        }
        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);
        }
Beispiel #3
0
        public async Task Ensure_we_can_add_with_auto_increment_diff_name()
        {
            var testTableItem = new TableWithAutoIncrementPrimaryKey()
            {
                Name = "Michale", SomeNumber = 33
            };
            await Sut.Add(new TableWithAutoIncrementPrimaryKeyDiffSqlName(testTableItem));

            var resultInDb = DataBaseScriptRunnerAndBuilder.GetAll <TableWithAutoIncrementPrimaryKey>(Connection);
            var items      = resultInDb as TableWithAutoIncrementPrimaryKey[] ?? resultInDb.ToArray();

            Assert.AreEqual(1, items.Length);
            var test = items.FirstOrDefault();

            Assert.IsNotNull(test);
            Assert.IsNotNull(test.Id);
            Assert.True(test.Id > 0);
            Assert.AreEqual(testTableItem.Name, test.Name);
            Assert.AreEqual(testTableItem.SomeNumber, test.SomeNumber);
        }
Beispiel #4
0
        public void Ensure_we_can_add_with_null_field_for_other_values()
        {
            var testTableItem = new TableWithAutoIncrementPrimaryKey()
            {
                Name = "Michale", SomeNumber = null
            };

            Sut.Add(testTableItem);

            var resultInDb = DataBaseScriptRunnerAndBuilder.GetAll <TableWithAutoIncrementPrimaryKey>(Connection);
            var items      = resultInDb as TableWithAutoIncrementPrimaryKey[] ?? resultInDb.ToArray();

            Assert.AreEqual(1, items.Length);
            var test = items.FirstOrDefault();

            Assert.IsNotNull(test);
            Assert.IsNotNull(test.Id);
            Assert.True(test.Id > 0);
            Assert.AreEqual(testTableItem.Name, test.Name);
            Assert.IsNull(test.SomeNumber);
        }