Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Issues #21 and #22
Browse files Browse the repository at this point in the history
  • Loading branch information
diegobrum committed Jun 16, 2015
1 parent fc42330 commit 61cd837
Show file tree
Hide file tree
Showing 16 changed files with 268 additions and 5 deletions.
2 changes: 1 addition & 1 deletion SolrExpress.Core/ParameterValue/SingleValue.cs
Expand Up @@ -47,7 +47,7 @@ public void Validate(out bool isValid, out string errorMessage)
errorMessage = string.Empty;

var solrFieldAttribute = UtilHelper.GetSolrFieldAttributeFromPropertyInfo(this._expression);
//TODO: Unit test

if (solrFieldAttribute != null && !solrFieldAttribute.Indexed)
{
isValid = false;
Expand Down
40 changes: 40 additions & 0 deletions SolrExpress.Solr4.Tests/Parameter/FieldListParameterTests.cs
Expand Up @@ -28,5 +28,45 @@ public void FieldsParameter001()
Assert.AreEqual(1, container.Count);
Assert.AreEqual("fl=Id,Score", container[0]);
}

/// <summary>
/// Where Using a FieldListParameter instance
/// When Create the instance with an expression using a field indicated with "index=false" and invoke Validate method
/// What Returns valid=false
/// </summary>
[TestMethod]
public void FieldsParameter002()
{
// Arrange
bool actual;
string dummy;
var parameter = new FieldListParameter<TestDocumentWithAttribute>(q => q.NotStored);

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsFalse(actual);
}

/// <summary>
/// Where Using a FieldListParameter instance
/// When Create the instance with an expression using a field indicated with "index=true" and invoke Validate method
/// What Returns valid=true
/// </summary>
[TestMethod]
public void FieldsParameter003()
{
// Arrange
bool actual;
string dummy;
var parameter = new FieldListParameter<TestDocumentWithAttribute>(q => q.Stored);

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsTrue(actual);
}
}
}
40 changes: 40 additions & 0 deletions SolrExpress.Solr4.Tests/Parameter/SpatialFilterParameterTests.cs
Expand Up @@ -52,5 +52,45 @@ public void SpatialFilterParameter002()
Assert.AreEqual("pt=-1.1,-2.2", container[1]);
Assert.AreEqual("d=5.5", container[2]);
}

/// <summary>
/// Where Using a SpatialFilterParameter instance
/// When Create the instance with an expression using a field indicated with "index=false" and invoke Validate method
/// What Returns valid=false
/// </summary>
[TestMethod]
public void SpatialFilterParameter003()
{
// Arrange
bool actual;
string dummy;
var parameter = new SpatialFilterParameter<TestDocumentWithAttribute>(SolrSpatialFunctionType.Geofilt, q => q.NotIndexed, new GeoCoordinate(), 0);

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsFalse(actual);
}

/// <summary>
/// Where Using a SpatialFilterParameter instance
/// When Create the instance with an expression using a field indicated with "index=true" and invoke Validate method
/// What Returns valid=true
/// </summary>
[TestMethod]
public void SpatialFilterParameter004()
{
// Arrange
bool actual;
string dummy;
var parameter = new SpatialFilterParameter<TestDocumentWithAttribute>(SolrSpatialFunctionType.Geofilt, q => q.Indexed, new GeoCoordinate(), 0);

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsTrue(actual);
}
}
}
1 change: 1 addition & 0 deletions SolrExpress.Solr4.Tests/SolrExpress.Solr4.Tests.csproj
Expand Up @@ -78,6 +78,7 @@
<Compile Include="Parameter\SpatialFilterParameterTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestDocument.cs" />
<Compile Include="TestDocumentWithAttribute.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SolrExpress.Core\SolrExpress.Core.csproj">
Expand Down
20 changes: 20 additions & 0 deletions SolrExpress.Solr4.Tests/TestDocumentWithAttribute.cs
@@ -0,0 +1,20 @@
using SolrExpress.Core.Attribute;
using SolrExpress.Core.Query;

namespace SolrExpress.Solr4.Tests
{
public class TestDocumentWithAttribute : IDocument
{
[SolrField("Indexed", Indexed = true)]
public string Indexed { get; set; }

[SolrField("NotIndexed", Indexed = false)]
public string NotIndexed { get; set; }

[SolrField("Stored", Stored = true)]
public string Stored { get; set; }

[SolrField("NotStored", Stored = false)]
public string NotStored { get; set; }
}
}
2 changes: 1 addition & 1 deletion SolrExpress.Solr4/Parameter/FieldListParameter.cs
Expand Up @@ -61,7 +61,7 @@ public void Validate(out bool isValid, out string errorMessage)
errorMessage = string.Empty;

var solrFieldAttribute = UtilHelper.GetSolrFieldAttributeFromPropertyInfo(this._expression);
//TODO: Unit test

if (solrFieldAttribute != null && !solrFieldAttribute.Stored)
{
isValid = false;
Expand Down
2 changes: 1 addition & 1 deletion SolrExpress.Solr4/Parameter/SpatialFilterParameter.cs
Expand Up @@ -62,7 +62,7 @@ public void Validate(out bool isValid, out string errorMessage)
errorMessage = string.Empty;

var solrFieldAttribute = UtilHelper.GetSolrFieldAttributeFromPropertyInfo(this._expression);
//TODO: Unit test

if (solrFieldAttribute != null && !solrFieldAttribute.Indexed)
{
isValid = false;
Expand Down
40 changes: 40 additions & 0 deletions SolrExpress.Solr5.Tests/Parameter/FieldsParameterTests.cs
Expand Up @@ -36,5 +36,45 @@ public void FieldsParameter001()
// Assert
Assert.AreEqual(expected.ToString(), actual);
}

/// <summary>
/// Where Using a FieldsParameter instance
/// When Create the instance with an expression using a field indicated with "index=false" and invoke Validate method
/// What Returns valid=false
/// </summary>
[TestMethod]
public void FieldsParameter002()
{
// Arrange
bool actual;
string dummy;
var parameter = new FieldsParameter<TestDocumentWithAttribute>(q => q.NotStored);

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsFalse(actual);
}

/// <summary>
/// Where Using a FieldsParameter instance
/// When Create the instance with an expression using a field indicated with "index=true" and invoke Validate method
/// What Returns valid=true
/// </summary>
[TestMethod]
public void FieldsParameter003()
{
// Arrange
bool actual;
string dummy;
var parameter = new FieldsParameter<TestDocumentWithAttribute>(q => q.Stored);

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsTrue(actual);
}
}
}
40 changes: 40 additions & 0 deletions SolrExpress.Solr5.Tests/Parameter/SpatialFilterParameterTests.cs
Expand Up @@ -66,5 +66,45 @@ public void SpatialFilterParameter002()
// Assert
Assert.AreEqual(expected.ToString(), actual);
}

/// <summary>
/// Where Using a SpatialFilterParameter instance
/// When Create the instance with an expression using a field indicated with "index=false" and invoke Validate method
/// What Returns valid=false
/// </summary>
[TestMethod]
public void SpatialFilterParameter003()
{
// Arrange
bool actual;
string dummy;
var parameter = new SpatialFilterParameter<TestDocumentWithAttribute>(SolrSpatialFunctionType.Geofilt, q => q.NotIndexed, new GeoCoordinate(), 0);

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsFalse(actual);
}

/// <summary>
/// Where Using a SpatialFilterParameter instance
/// When Create the instance with an expression using a field indicated with "index=true" and invoke Validate method
/// What Returns valid=true
/// </summary>
[TestMethod]
public void SpatialFilterParameter004()
{
// Arrange
bool actual;
string dummy;
var parameter = new SpatialFilterParameter<TestDocumentWithAttribute>(SolrSpatialFunctionType.Geofilt, q => q.Indexed, new GeoCoordinate(), 0);

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsTrue(actual);
}
}
}
1 change: 1 addition & 0 deletions SolrExpress.Solr5.Tests/SolrExpress.Solr5.Tests.csproj
Expand Up @@ -78,6 +78,7 @@
<Compile Include="Parameter\SpatialFilterParameterTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestDocument.cs" />
<Compile Include="TestDocumentWithAttribute.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SolrExpress.Core\SolrExpress.Core.csproj">
Expand Down
20 changes: 20 additions & 0 deletions SolrExpress.Solr5.Tests/TestDocumentWithAttribute.cs
@@ -0,0 +1,20 @@
using SolrExpress.Core.Attribute;
using SolrExpress.Core.Query;

namespace SolrExpress.Solr5.Tests
{
public class TestDocumentWithAttribute : IDocument
{
[SolrField("Indexed", Indexed = true)]
public string Indexed { get; set; }

[SolrField("NotIndexed", Indexed = false)]
public string NotIndexed { get; set; }

[SolrField("Stored", Stored = true)]
public string Stored { get; set; }

[SolrField("NotStored", Stored = false)]
public string NotStored { get; set; }
}
}
2 changes: 1 addition & 1 deletion SolrExpress.Solr5/Parameter/FieldsParameter.cs
Expand Up @@ -51,7 +51,7 @@ public void Validate(out bool isValid, out string errorMessage)
errorMessage = string.Empty;

var solrFieldAttribute = UtilHelper.GetSolrFieldAttributeFromPropertyInfo(this._expression);
//TODO: Unit test

if (solrFieldAttribute != null && !solrFieldAttribute.Stored)
{
isValid = false;
Expand Down
2 changes: 1 addition & 1 deletion SolrExpress.Solr5/Parameter/SpatialFilterParameter.cs
Expand Up @@ -66,7 +66,7 @@ public void Validate(out bool isValid, out string errorMessage)
errorMessage = string.Empty;

var solrFieldAttribute = UtilHelper.GetSolrFieldAttributeFromPropertyInfo(this._expression);
//TODO: Unit test

if (solrFieldAttribute != null && !solrFieldAttribute.Indexed)
{
isValid = false;
Expand Down
40 changes: 40 additions & 0 deletions SolrExpress.Tests/ParameterValue/SingleValueTests.cs
Expand Up @@ -25,5 +25,45 @@ public void SingleValue001()
// Assert
Assert.AreEqual(expected, actual);
}

/// <summary>
/// Where Using a SingleValue instance
/// When Create the instance with an expression using a field indicated with "index=false" and invoke Validate method
/// What Returns valid=false
/// </summary>
[TestMethod]
public void SingleValue002()
{
// Arrange
bool actual;
string dummy;
var parameter = new SingleValue<TestDocumentWithAttribute>(q => q.NotIndexed, "xpto");

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsFalse(actual);
}

/// <summary>
/// Where Using a SingleValue instance
/// When Create the instance with an expression using a field indicated with "index=true" and invoke Validate method
/// What Returns valid=true
/// </summary>
[TestMethod]
public void SingleValue003()
{
// Arrange
bool actual;
string dummy;
var parameter = new SingleValue<TestDocumentWithAttribute>(q => q.Indexed, "xpto");

// Act
parameter.Validate(out actual, out dummy);

// Assert
Assert.IsTrue(actual);
}
}
}
1 change: 1 addition & 0 deletions SolrExpress.Tests/SolrExpress.Tests.csproj
Expand Up @@ -65,6 +65,7 @@
<Compile Include="Query\SolrQueryableTests.cs" />
<Compile Include="TestDocument.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestDocumentWithAttribute.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
20 changes: 20 additions & 0 deletions SolrExpress.Tests/TestDocumentWithAttribute.cs
@@ -0,0 +1,20 @@
using SolrExpress.Core.Attribute;
using SolrExpress.Core.Query;

namespace SolrExpress.Tests
{
public class TestDocumentWithAttribute : IDocument
{
[SolrFieldAttribute("Indexed", Indexed = true)]
public string Indexed { get; set; }

[SolrFieldAttribute("NotIndexed", Indexed = false)]
public string NotIndexed { get; set; }

[SolrFieldAttribute("Stored", Stored = true)]
public string Stored { get; set; }

[SolrFieldAttribute("NotStored", Stored = false)]
public string NotStored { get; set; }
}
}

0 comments on commit 61cd837

Please sign in to comment.