Here are the examples of the csharp api NUnit.Framework.Constraints.EqualConstraint.Using(System.Func) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
124 Examples
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_of_month_IS_rendered_to_caml_properly()
{
var operand = new DateTimeValueOperand(Camlex.Month, false);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\"><Month /></Value>").Using(new CamlComparer()));
}
19
Source : ValuesValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_operand_IS_transformed_to_caml_properly()
{
var values = new List<IOperand>();
values.Add(new BooleanValueOperand(true));
values.Add(new TextValueOperand("test"));
values.Add(new IntegerValueOperand(1));
var operand = new ValuesValueOperand(values);
var caml = operand.ToCaml().ToString();
string expected =
"<Values>" +
" <Value Type=\"Boolean\">1</Value>" +
" <Value Type=\"Text\">test</Value>" +
" <Value Type=\"Integer\">1</Value>" +
"</Values>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : AndAlsoOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_andalso_with_2_eq_IS_translated_to_caml_properly()
{
// arrange
var leftOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
var rightOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
leftOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq1"));
rightOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq2"));
var resultBuilder = new OperationResultBuilder();
var operation = new AndAlsoOperation(resultBuilder, leftOperation, rightOperation);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<And>
<Eq1 />
<Eq2 />
</And>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : AndAlsoOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_andalso_with_2_nested_andalso_IS_translated_to_caml_properly()
{
// arrange
var leftEqOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
var rightEqOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
var resultBuilder = new OperationResultBuilder();
var leftOperation = new AndAlsoOperation(resultBuilder, leftEqOperation, rightEqOperation);
var rightOperation = new AndAlsoOperation(resultBuilder, leftEqOperation, rightEqOperation);
leftEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq1"));
rightEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq2"));
var operation = new AndAlsoOperation(resultBuilder, leftOperation, rightOperation);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<And>
<And>
<Eq1 />
<Eq2 />
</And>
<And>
<Eq1 />
<Eq2 />
</And>
</And>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : ArrayOperationTest.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub1 = MockRepository.GenerateStub<FieldRefOperand>("");
var fieldRefOperandStub2 = MockRepository.GenerateStub<FieldRefOperand>("");
fieldRefOperandStub1.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub1"));
fieldRefOperandStub2.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub2"));
var resultBuilder = new OperationResultBuilder();
var operation = new ArrayOperation(resultBuilder, fieldRefOperandStub1, fieldRefOperandStub2);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<fieldRefOperandStub1 />
<fieldRefOperandStub2 />";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : BeginsWithOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_beginswith_operation_IS_renderedtocaml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<TextValueOperand>("");
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new BeginsWithOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
var caml = operation.ToResult().ToString();
// replacedert
const string expected =
@"<BeginsWith>
<fieldRefOperandStub />
<valueOperandStub />
</BeginsWith>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : ContainsOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_contains_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<TextValueOperand>("");
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new ContainsOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
var caml = operation.ToResult().ToString();
// replacedert
const string expected =
@"<Contains>
<fieldRefOperandStub />
<valueOperandStub />
</Contains>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : DateRangesOverlapOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_daterangesoverlap_operation_IS_rendered_to_caml_properly()
{
// arrange
var startFieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var stopFieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var recurrenceFieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var dateTimevalueOperandStub = MockRepository.GenerateStub<TextValueOperand>("");
startFieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("startFieldRefOperandStub"));
stopFieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("stopFieldRefOperandStub"));
recurrenceFieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("recurrenceFieldRefOperandStub"));
dateTimevalueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("dateTimevalueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new DateRangesOverlapOperation(resultBuilder,
startFieldRefOperandStub, stopFieldRefOperandStub, recurrenceFieldRefOperandStub, dateTimevalueOperandStub);
// act
var caml = operation.ToResult().ToString();
// replacedert
const string expected =
@"<DateRangesOverlap>
<startFieldRefOperandStub />
<stopFieldRefOperandStub />
<recurrenceFieldRefOperandStub />
<dateTimevalueOperandStub />
</DateRangesOverlap>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : EqOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_eq_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<IntegerValueOperand>(0);
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new EqOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<Eq>
<fieldRefOperandStub />
<valueOperandStub />
</Eq>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : GeqOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_geq_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<IntegerValueOperand>(0);
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new GeqOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<Geq>
<fieldRefOperandStub />
<valueOperandStub />
</Geq>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : GtOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_gt_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<IntegerValueOperand>(0);
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new GtOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<Gt>
<fieldRefOperandStub />
<valueOperandStub />
</Gt>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : InOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_in_operation_IS_rendered_to_caml_properly()
{
var f = MockRepository.GenerateStub<FieldRefOperand>("");
var v = MockRepository.GenerateStub<IntegerValueOperand>(1);
f.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
v.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var op = new InOperation(new OperationResultBuilder(), f, v);
string caml = op.ToResult().ToString();
string expected =
@"<In>
<fieldRefOperandStub />
<valueOperandStub />
</In>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : IncludesOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_includes_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<TextValueOperand>("");
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new IncludesOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
var caml = operation.ToResult().ToString();
// replacedert
const string expected =
@"<Includes>
<fieldRefOperandStub />
<valueOperandStub />
</Includes>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : IsNotNullOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_isnotnull_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<IntegerValueOperand>(0);
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new IsNotNullOperation(resultBuilder, fieldRefOperandStub);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<IsNotNull>
<fieldRefOperandStub />
</IsNotNull>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : IsNullOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_isnull_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<IntegerValueOperand>(0);
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new IsNullOperation(resultBuilder, fieldRefOperandStub);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<IsNull>
<fieldRefOperandStub />
</IsNull>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : JoinOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_join_operation_IS_rendered_to_caml_properly()
{
var f = MockRepository.GenerateStub<FieldRefOperand>("");
var v = MockRepository.GenerateStub<IntegerValueOperand>(1);
f.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
v.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var op = new JoinOperation(new OperationResultBuilder(), f, v, JoinType.Inner);
string caml = op.ToResult().ToString();
string expected =
"<Join Type=\"INNER\" ListAlias=\"\">" +
" <Eq>" +
" <fieldRefOperandStub />" +
" <valueOperandStub />" +
" </Eq>" +
"</Join>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : LeqOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_leq_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<IntegerValueOperand>(0);
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new LeqOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<Leq>
<fieldRefOperandStub />
<valueOperandStub />
</Leq>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : LtOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_lt_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<IntegerValueOperand>(0);
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new LtOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<Lt>
<fieldRefOperandStub />
<valueOperandStub />
</Lt>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : MembershipOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_membership_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var membershipTypeStub = MockRepository.GenerateStub<Camlex.MembershipType>();
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
membershipTypeStub.Stub(o => o.ToString()).Return("membershipTypeStub");
var resultBuilder = new OperationResultBuilder();
var operation = new MembershipOpeartion(resultBuilder,
fieldRefOperandStub, membershipTypeStub);
// act
var caml = operation.ToResult().ToString();
// replacedert
const string expected =
@"<Membership Type=""membershipTypeStub"">
<fieldRefOperandStub />
</Membership>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : NeqOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_neq_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<IntegerValueOperand>(0);
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new NeqOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<Neq>
<fieldRefOperandStub />
<valueOperandStub />
</Neq>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : OrElseOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_orelse_with_3_nested_orelse_IS_translated_to_caml_properly()
{
// arrange
var leftEqOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
var rightEqOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
var resultBuilder = new OperationResultBuilder();
var leftOperation1 = new OrElseOperation(resultBuilder, leftEqOperation, rightEqOperation);
var leftOperation2 = new OrElseOperation(resultBuilder, leftOperation1, rightEqOperation);
leftEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq1"));
rightEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq2"));
var operation = new OrElseOperation(resultBuilder, leftOperation2, rightEqOperation);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<Or>
<Or>
<Or>
<Eq1 />
<Eq2 />
</Or>
<Eq2 />
</Or>
<Eq2 />
</Or>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : ReOperandBuilderFromCamlTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_WHEN_type_attr_has_correct_value_THEN_value_operand_is_sucessfully_created()
{
var b = new ReOperandBuilderFromCaml();
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"Text\">foo</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"Text\">foo</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"Integer\">123</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"Integer\">123</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"Number\">1.23</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"Number\">1.23</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"Boolean\">1</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"Boolean\">1</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"Boolean\">0</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"Boolean\">0</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\">2010-02-01T03:04:05Z</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\">2010-02-01T03:04:05Z</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\" IncludeTimeValue=\"True\">2010-02-01T03:04:05Z</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\" IncludeTimeValue=\"True\">2010-02-01T03:04:05Z</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\" StorageTZ=\"True\">2010-02-01T03:04:05Z</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\" StorageTZ=\"True\">2010-02-01T03:04:05Z</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\" IncludeTimeValue=\"True\" StorageTZ=\"True\">2010-02-01T03:04:05Z</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\" IncludeTimeValue=\"True\" StorageTZ=\"True\">2010-02-01T03:04:05Z</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\"><Now /></Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\"><Now /></Value>").Using(new CamlComparer()));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\"><Today /></Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\"><Today /></Value>").Using(new CamlComparer()));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\"><Today OffsetDays=\"5\" /></Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\"><Today OffsetDays=\"5\" /></Value>").Using(new CamlComparer()));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\"><Week /></Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\"><Week /></Value>").Using(new CamlComparer()));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\"><Month /></Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\"><Month /></Value>").Using(new CamlComparer()));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"DateTime\"><Year /></Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"DateTime\"><Year /></Value>").Using(new CamlComparer()));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"Guid\">{AD524A0C-D90E-4C04-B6FB-CB6E9F6CA7BD}</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"Guid\">ad524a0c-d90e-4c04-b6fb-cb6e9f6ca7bd</Value>"));
var valueOperand = b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"Lookup\">1</Value></Operation>"), false);
replacedert.IsInstanceOf<LookupValueValueOperand>(valueOperand);
replacedert.That(valueOperand.ToCaml().ToString(), Is.EqualTo("<Value Type=\"Lookup\">1</Value>"));
valueOperand = b.CreateValueOperand(XmlHelper.Get("<Operation><FieldRef Name=\"Status\" LookupId=\"True\" /><Value Type=\"Lookup\">1</Value></Operation>"), false);
replacedert.IsInstanceOf<LookupIdValueOperand>(valueOperand);
replacedert.That(valueOperand.ToCaml().ToString(), Is.EqualTo("<Value Type=\"Lookup\">1</Value>"));
var userOperand = b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"User\">test</Value></Operation>"), false);
replacedert.IsInstanceOf<GenericStringBasedValueOperand>(userOperand);
replacedert.That(userOperand.ToCaml().ToString(), Is.EqualTo("<Value Type=\"User\">test</Value>"));
userOperand = b.CreateValueOperand(XmlHelper.Get("<Operation><FieldRef Name=\"Status\" LookupId=\"True\" /><Value Type=\"User\">1</Value></Operation>"), false);
replacedert.IsInstanceOf<UserIdValueOperand>(userOperand);
replacedert.That(userOperand.ToCaml().ToString(), Is.EqualTo("<Value Type=\"User\">1</Value>"));
replacedert.That(b.CreateValueOperand(XmlHelper.Get("<Operation><Value Type=\"Note\">foo</Value></Operation>"), false).ToCaml().ToString(),
Is.EqualTo("<Value Type=\"Note\">foo</Value>"));
}
19
Source : MixQueryTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_view_fields_collection_IS_mixed_with_several_view_fields_correctly()
{
string existingQuery =
" <FieldRef Name=\"Modified\" />" +
" <FieldRef Name=\"ModifiedBy\" />";
string expected =
" <FieldRef Name=\"Modified\" />" +
" <FieldRef Name=\"ModifiedBy\" />" +
" <FieldRef Name=\"replacedle\" />" +
" <FieldRef Name=\"State\" />";
var exprs = new List<string>();
exprs.Add("replacedle");
exprs.Add("State");
var query = Camlex.Query().ViewFields(existingQuery, exprs).ToString();
replacedert.That(query, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : CamlexIncludesTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_expresstion_with_includes_native_syntax_IS_translated_successfully()
{
string caml = Camlex.Query().Where(x => ((int)x["Foo"]).Includes(1)).ToString();
string expected =
" <Where>" +
" <Includes>" +
" <FieldRef Name=\"Foo\" />" +
" <Value Type=\"Integer\">1</Value>" +
" </Includes>" +
" </Where>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : CamlexJoinsTest.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_expressions_with_different_methods_IS_translated_successfully()
{
var expressionsList = new List<Expression<Func<SPLisreplacedem, bool>>>
{
x => (int) x["ID"] == 1,
y => (int) y["ID"] == 2,
z => (int) z["ID"] == 3
};
Expression<Func<SPLisreplacedem, bool>> additionalExpression = (w => (string)w["replacedle"] == "Test");
var combinedExpressions = ExpressionsHelper.CombineOr(expressionsList);
var finalExpression = ExpressionsHelper.CombineAnd(new[] {combinedExpressions, additionalExpression});
var caml = Camlex.Query().Where(finalExpression).ToString();
var expected =
" <Where>" +
" <And>" +
" <Or>" +
" <Or>" +
" <Eq>" +
" <FieldRef Name=\"ID\" />" +
" <Value Type=\"Integer\">1</Value>" +
" </Eq>" +
" <Eq>" +
" <FieldRef Name=\"ID\" />" +
" <Value Type=\"Integer\">2</Value>" +
" </Eq>" +
" </Or>" +
" <Eq>" +
" <FieldRef Name=\"ID\" />" +
" <Value Type=\"Integer\">3</Value>" +
" </Eq>" +
" </Or>" +
" <Eq>" +
" <FieldRef Name=\"replacedle\" />" +
" <Value Type=\"Text\">Test</Value>" +
" </Eq>" +
" </And>" +
" </Where>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : CamlexOrderByTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_multiple_orderby_expression_IS_translated_sucessfully()
{
var caml = Camlex.Query().OrderBy(
x => new[] { x["field1"], x["field2"] as Camlex.Desc, x["field3"] as Camlex.Asc }).ToString();
var expected =
" <OrderBy>" +
" <FieldRef Name=\"field1\" />" +
" <FieldRef Name=\"field2\" Ascending=\"False\" />" +
" <FieldRef Name=\"field3\" Ascending=\"True\" />" +
" </OrderBy>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : CamlexViewFieldsTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_viewfield_non_const_replacedle_IS_translated_sucessfully()
{
Func<string> f = () => "replacedle";
string caml =
Camlex.Query().ViewFields(x => x[f()]);
string expected = "<FieldRef Name=\"replacedle\" />";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : CamlexViewFieldsTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_dynamic_view_fields_with_fields_names_expression_IS_translated_sucessfully()
{
var items = new [] { "replacedle", "FileRef" };
string caml =
Camlex.Query().ViewFields(items);
string expected = "<FieldRef Name=\"replacedle\" /><FieldRef Name=\"FileRef\" />";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_with_includetimevalue_IS_rendered_to_caml_properly()
{
var dateTime = DateTime.Now;
var operand = new DateTimeValueOperand(dateTime, true);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\" IncludeTimeValue=\"True\">" + dateTime.ToString("s") + "Z</Value>").Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_without_includetimevalue_IS_rendered_to_caml_properly()
{
var dateTime = DateTime.Now;
var operand = new DateTimeValueOperand(dateTime, false);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\">" + dateTime.ToString("s") + "Z</Value>").Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_with_storagetz_IS_rendered_to_caml_properly()
{
var dateTime = DateTime.Now;
var operand = new DateTimeValueOperand(dateTime, false, true);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\" StorageTZ=\"True\">" + dateTime.ToString("s") + "Z</Value>").Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_without_storagetz_IS_rendered_to_caml_properly()
{
var dateTime = DateTime.Now;
var operand = new DateTimeValueOperand(dateTime, false, false);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\">" + dateTime.ToString("s") + "Z</Value>").Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_with_includetimevalue_and_storagetz_IS_rendered_to_caml_properly()
{
var dateTime = DateTime.Now;
var operand = new DateTimeValueOperand(dateTime, true, true);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\" IncludeTimeValue=\"True\" StorageTZ=\"True\">" + dateTime.ToString("s") + "Z</Value>").Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_of_now_IS_rendered_to_caml_properly()
{
var operand = new DateTimeValueOperand(Camlex.Now, false);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\"><Now /></Value>").Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_of_today_IS_rendered_to_caml_properly()
{
var operand = new DateTimeValueOperand(Camlex.Today, false);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\"><Today /></Value>").Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_of_today_and_offsetdays_IS_rendered_to_caml_properly()
{
int offsetDays = 4;
var operand = new DateTimeValueOperand(Camlex.Today, false, offsetDays);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\"><Today OffsetDays=\"" + offsetDays + "\" /></Value>").Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_of_week_IS_rendered_to_caml_properly()
{
var operand = new DateTimeValueOperand(Camlex.Week, false);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\"><Week /></Value>").Using(new CamlComparer()));
}
19
Source : DateTimeValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_datetime_value_of_year_IS_rendered_to_caml_properly()
{
var operand = new DateTimeValueOperand(Camlex.Year, false);
var caml = operand.ToCaml().ToString();
replacedert.That(caml, Is.EqualTo("<Value Type=\"DateTime\"><Year /></Value>").Using(new CamlComparer()));
}
19
Source : AndAlsoOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_andalso_with_nested_andalso_IS_translated_to_caml_properly()
{
// arrange
var leftEqOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
var rightEqOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
var resultBuilder = new OperationResultBuilder();
var leftOperation = new AndAlsoOperation(resultBuilder, leftEqOperation, rightEqOperation);
leftEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq1"));
rightEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq2"));
var operation = new AndAlsoOperation(resultBuilder, leftOperation, rightEqOperation);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<And>
<And>
<Eq1 />
<Eq2 />
</And>
<Eq2 />
</And>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : AndAlsoOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_andalso_with_3_nested_andalso_IS_translated_to_caml_properly()
{
// arrange
var leftEqOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
var rightEqOperation = MockRepository.GenerateStub<EqOperation>(null, null, null);
var resultBuilder = new OperationResultBuilder();
var leftOperation1 = new AndAlsoOperation(resultBuilder, leftEqOperation, rightEqOperation);
var leftOperation2 = new AndAlsoOperation(resultBuilder, leftOperation1, rightEqOperation);
leftEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq1"));
rightEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq2"));
var operation = new AndAlsoOperation(resultBuilder, leftOperation2, rightEqOperation);
// act
string caml = operation.ToResult().ToString();
// replacedert
string expected =
@"<And>
<And>
<And>
<Eq1 />
<Eq2 />
</And>
<Eq2 />
</And>
<Eq2 />
</And>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : NotIncludesOperationTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_not_includes_operation_IS_rendered_to_caml_properly()
{
// arrange
var fieldRefOperandStub = MockRepository.GenerateStub<FieldRefOperand>("");
var valueOperandStub = MockRepository.GenerateStub<TextValueOperand>("");
fieldRefOperandStub.Stub(o => o.ToCaml()).Return(new XElement("fieldRefOperandStub"));
valueOperandStub.Stub(o => o.ToCaml()).Return(new XElement("valueOperandStub"));
var resultBuilder = new OperationResultBuilder();
var operation = new NotIncludesOperation(resultBuilder, fieldRefOperandStub, valueOperandStub);
// act
var caml = operation.ToResult().ToString();
// replacedert
const string expected =
@"<NotIncludes>
<fieldRefOperandStub />
<valueOperandStub />
</NotIncludes>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : BooleanValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_operand_with_true_IS_conveted_to_expression_correctly()
{
var op = new BooleanValueOperand(true);
var expr = op.ToExpression();
replacedert.That(expr.ToString(), Is.EqualTo("true").Using(new CaseInsensetiveComparer()));
}
19
Source : BooleanValueOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_operand_with_false_IS_conveted_to_expression_correctly()
{
var op = new BooleanValueOperand(false);
var expr = op.ToExpression();
replacedert.That(expr.ToString(), Is.EqualTo("false").Using(new CaseInsensetiveComparer()));
}
19
Source : FieldRefOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_field_ref_operand_with_guid_IS_converted_to_expression_correctly()
{
var id = new Guid("{7742D3F8-A2B7-430F-BDEB-B2DDBF853901}");
var op = new FieldRefOperand(id);
var expr = op.ToExpression();
replacedert.That(expr.ToString(), Is.EqualTo("x.get_Item(new Guid(\"7742d3f8-a2b7-430f-bdeb-b2ddbf853901\"))").Using(new CaseInsensetiveComparer()));
}
19
Source : FieldRefOperandTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_field_ref_operand_with_filed_name_IS_converted_to_expression_correctly()
{
var op = new FieldRefOperand("replacedle");
var expr = op.ToExpression();
replacedert.That(expr.ToString(), Is.EqualTo("x.get_Item(\"replacedle\")").Using(new CaseInsensetiveComparer()));
}
19
Source : MixQueryTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_existing_single_eq_expression_IS_mixed_with_single_expression_correctly_using_and()
{
string existingQuery =
" <Where>" +
" <Eq>" +
" <FieldRef Name=\"replacedle\" />" +
" <Value Type=\"Text\">testValue</Value>" +
" </Eq>" +
" </Where>";
string expected =
"<Where>" +
" <And>" +
" <Eq>" +
" <FieldRef Name=\"replacedle\" />" +
" <Value Type=\"Text\">foo</Value>" +
" </Eq>" +
" <Eq>" +
" <FieldRef Name=\"replacedle\" />" +
" <Value Type=\"Text\">testValue</Value>" +
" </Eq>" +
" </And>" +
"</Where>";
var query = Camlex.Query().WhereAll(existingQuery, x => (string) x["replacedle"] == "foo").ToString();
replacedert.That(query, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : CamlexLookupTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_lookup_multi_id_field_ref_with_guid_IS_translated_successfully()
{
var guid = new Guid("{4feaf1f3-5b04-4d93-b0fc-4e48d0c60eed}");
string caml = Camlex.Query().Where(x => x[guid] == (DataTypes.LookupMultiId)"123").ToString();
string expected =
" <Where>" +
" <Eq>" +
" <FieldRef ID=\"4feaf1f3-5b04-4d93-b0fc-4e48d0c60eed\" LookupId=\"True\" />" +
" <Value Type=\"LookupMulti\">123</Value>" +
" </Eq>" +
" </Where>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : CamlexLookupTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_lookup_multi_value_IS_translated_successfully()
{
string caml = Camlex.Query().Where(x => x["Ref"] == (DataTypes.LookupMultiValue)"123").ToString();
string expected =
" <Where>" +
" <Eq>" +
" <FieldRef Name=\"Ref\" />" +
" <Value Type=\"LookupMulti\">123</Value>" +
" </Eq>" +
" </Where>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : CamlexOrderByTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_single_orderby_expression_IS_translated_sucessfully()
{
var caml = Camlex.Query().OrderBy(x => x["field1"] as Camlex.Desc).ToString();
var expected =
" <OrderBy>" +
" <FieldRef Name=\"field1\" Ascending=\"False\" />" +
" </OrderBy>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
19
Source : CamlexOrderByTests.cs
with Microsoft Public License
from sadomovalex
with Microsoft Public License
from sadomovalex
[Test]
public void test_THAT_orderby_expression_with_non_constant_parameters_IS_translated_sucessfully()
{
bool b = true;
var caml = Camlex.Query().OrderBy(x => new[] { x[b ? SPBuiltInFieldId.replacedle : SPBuiltInFieldId.UniqueId], x[SPBuiltInFieldId.Modified] as Camlex.Asc }).ToString();
var expected =
"<OrderBy>" +
" <FieldRef ID=\"fa564e0f-0c70-4ab9-b863-0177e6ddd247\" />" +
" <FieldRef ID=\"28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f\" Ascending=\"True\" />" +
"</OrderBy>";
replacedert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
}
See More Examples