Пример #1
0
            public void adds_entity_to_db_set()
            {
                _data = new List <Domain>();
                var dbSet = DbSetMock.MockDbSet(_data);

                dbSet.Object.FirstOrAddDescending(x => x.Key == "test", () => new Domain("test", 1), x => x.Order);

                Assert.Single(_data);
            }
Пример #2
0
            public void does_not_add_entity_to_db_set()
            {
                _data = new List <Domain> {
                    new Domain("test", 1)
                };
                var dbSet = DbSetMock.MockDbSet(_data);

                dbSet.Object.FirstOrAdd(x => x.Key == "test", () => new Domain("test", 1));

                Assert.Single(_data);
            }
Пример #3
0
            public void returns_the_first_with_match()
            {
                _data = new List <Domain> {
                    new Domain("test", 1), new Domain("test", 2)
                };
                var dbSet = DbSetMock.MockDbSet(_data);

                var actual = dbSet.Object.FirstOrAdd(x => x.Key == "test", () => new Domain("test", 1));

                Assert.Equal(1, actual.Order);
            }
Пример #4
0
            public void returns_the_first_with_match_ordered(int first, int second, int expected)
            {
                _data = new List <Domain> {
                    new Domain("test", first), new Domain("test", second)
                };
                var dbSet = DbSetMock.MockDbSet(_data);

                var actual = dbSet.Object.FirstOrAddDescending(x => x.Key == "test", () => new Domain("test", 100), x => x.Order);

                Assert.Equal(expected, actual.Order);
            }