public void ItAllowsTheConnectionStringToBeSet()
        {
            const string connection = "some connection";

            var operation =
                new Update(SomeTable)
                    [
                        FirstColumn.WillBe(FirstValue)
                    ]
                    .ConnectTo(connection);

            operation.GetType().GetField("_connection", BindingFlagsToSeeAll).GetValue(operation).ToString().Should().Be(connection);
        }
예제 #2
0
        public Update this[params ColumnItem[] items]
        {
            get
            {
                var result = new Update(_tableName) {_connection = _connection, WhereContainer = _whereContainer};

                foreach (var item in items)
                {
                    result.Columns.Add(item);
                }

                return result;
            }
        }
        public void ItCopiesTheColumnsWhenTheConnectionStringIsSet()
        {
            var original = new Update(SomeTable)[FirstColumn.WillBe(FirstValue)];
            var record = original.ConnectTo("A");

            RetrieveValueFromObject(original, ColumnsKeyword).Should().Be(RetrieveValueFromObject(record, ColumnsKeyword));
        }
        public void ItCopiesTheColumnsWhenAWhereClauseIsAdded()
        {
            var original = new Update(SomeTable)[FirstColumn.WillBe(FirstValue)].ConnectTo("A");
            var record = original.Where(new Where());

            RetrieveValueFromObject(original, ColumnsKeyword).Should().Be(RetrieveValueFromObject(record, ColumnsKeyword));
        }
        public void ItCreatesANewUpdateWhenTheConnectionStringIsSet()
        {
            var original = new Update(SomeTable)[FirstColumn.WillBe(FirstValue)];
            var record = original.ConnectTo("A");

            original.Should().NotBe(record);
        }
        public void ItCreatesANewUpdateWhenTheColumnsAreSet()
        {
            var original = new Update(SomeTable)[FirstColumn.WillBe(FirstValue)];
            var record = original[SecondColumn.WillBe("")];

            original.Should().NotBe(record);
        }
        public void ItCreatesANewUpdateWhenAWhereClauseIsAdded()
        {
            var original = new Update(SomeTable)[FirstColumn.WillBe(FirstValue)];
            var record = original.Where(new Where());

            original.Should().NotBe(record);
        }
        public void ItCreatesACorrectQueryWithAWhereClause()
        {
            const string query = BasicQuery + " WHERE {1} = @{1}{3}";

            var firstColumnIsEqualToFirstValue = new Where()
                [
                    FirstColumn.IsEqualTo(FirstValue)
                ];

            var whereItems = WhereDeconstruction.RetrieveTheWhereItemUniqueNames(firstColumnIsEqualToFirstValue).First();

            var finalSql =
                new Update(SomeTable)
                    [
                        FirstColumn.WillBe(FirstValue),
                        SecondColumn.WillBe(SecondValue)
                    ]
                    .Where(firstColumnIsEqualToFirstValue)
                    .CreateSql();

            finalSql.Should().Be(string.Format(query, SomeTable, FirstColumn, SecondColumn, whereItems));
        }
        public void ItCopiesTheWhereContainerWhenTheConnectionStringIsSet()
        {
            var original = new Update(SomeTable)[FirstColumn.WillBe(FirstValue)].Where(new Where());
            var record = original.ConnectTo("A");

            RetrieveValueFromObject(original, WhereContainerKeyName)
                .Should()
                .Be(RetrieveValueFromObject(record, WhereContainerKeyName));
        }
        public void ItCopiesTheWhereContainerWhenTheColumnsAreSet()
        {
            var original = new Update(SomeTable)[FirstColumn.WillBe(FirstValue)].Where(new Where());
            var record = original[SecondColumn.WillBe("")];

            RetrieveValueFromObject(original, WhereContainerKeyName)
                .Should()
                .Be(RetrieveValueFromObject(record, WhereContainerKeyName));
        }
        public void ItCopiesTheConnectionWhenTheColumnsAreSet()
        {
            var original = new Update(SomeTable)[FirstColumn.WillBe(FirstValue)].ConnectTo("a");
            var record = original[SecondColumn.WillBe("")];

            RetrieveValueFromObject(original, ConnectionKeyword)
                .Should()
                .Be(RetrieveValueFromObject(record, ConnectionKeyword));
        }