-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSHARP-3315: Add tests for serializer Equals methods (work in progress).
- Loading branch information
Showing
35 changed files
with
5,712 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
tests/MongoDB.Bson.Tests/ObjectModel/MaterializedOnDemandBsonArrayTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* Copyright 2010-present MongoDB Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace MongoDB.Bson.Tests.ObjectModel | ||
{ | ||
public class MaterializedOnDemandBsonArraySerializerTests | ||
{ | ||
[Fact] | ||
public void Equals_derived_should_return_false() | ||
{ | ||
var x = new MaterializedOnDemandBsonArray.MaterializedOnDemandBsonArraySerializer(); | ||
var y = new DerivedFromMaterializedOnDemandBsonArraySerializer(); | ||
|
||
var result = x.Equals(y); | ||
|
||
result.Should().Be(false); | ||
} | ||
|
||
[Fact] | ||
public void Equals_null_should_return_false() | ||
{ | ||
var x = new MaterializedOnDemandBsonArray.MaterializedOnDemandBsonArraySerializer(); | ||
|
||
var result = x.Equals(null); | ||
|
||
result.Should().Be(false); | ||
} | ||
|
||
[Fact] | ||
public void Equals_object_should_return_false() | ||
{ | ||
var x = new MaterializedOnDemandBsonArray.MaterializedOnDemandBsonArraySerializer(); | ||
var y = new object(); | ||
|
||
var result = x.Equals(y); | ||
|
||
result.Should().Be(false); | ||
} | ||
|
||
[Fact] | ||
public void Equals_self_should_return_true() | ||
{ | ||
var x = new MaterializedOnDemandBsonArray.MaterializedOnDemandBsonArraySerializer(); | ||
|
||
var result = x.Equals(x); | ||
|
||
result.Should().Be(true); | ||
} | ||
|
||
[Fact] | ||
public void Equals_with_equal_fields_should_return_true() | ||
{ | ||
var x = new MaterializedOnDemandBsonArray.MaterializedOnDemandBsonArraySerializer(); | ||
var y = new MaterializedOnDemandBsonArray.MaterializedOnDemandBsonArraySerializer(); | ||
|
||
var result = x.Equals(y); | ||
|
||
result.Should().Be(true); | ||
} | ||
|
||
[Fact] | ||
public void GetHashCode_should_return_zero() | ||
{ | ||
var x = new MaterializedOnDemandBsonArray.MaterializedOnDemandBsonArraySerializer(); | ||
|
||
var result = x.GetHashCode(); | ||
|
||
result.Should().Be(0); | ||
} | ||
|
||
private class DerivedFromMaterializedOnDemandBsonArraySerializer : MaterializedOnDemandBsonArray.MaterializedOnDemandBsonArraySerializer | ||
{ | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
tests/MongoDB.Bson.Tests/ObjectModel/MaterializedOnDemandBsonDocumentTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* Copyright 2010-present MongoDB Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace MongoDB.Bson.Tests.ObjectModel | ||
{ | ||
public class MaterializedOnDemandBsonDocumentSerializerTests | ||
{ | ||
[Fact] | ||
public void Equals_derived_should_return_false() | ||
{ | ||
var x = new MaterializedOnDemandBsonDocumentSerializer(); | ||
var y = new DerivedFromMaterializedOnDemandBsonDocumentSerializer(); | ||
|
||
var result = x.Equals(y); | ||
|
||
result.Should().Be(false); | ||
} | ||
|
||
[Fact] | ||
public void Equals_null_should_return_false() | ||
{ | ||
var x = new MaterializedOnDemandBsonDocumentSerializer(); | ||
|
||
var result = x.Equals(null); | ||
|
||
result.Should().Be(false); | ||
} | ||
|
||
[Fact] | ||
public void Equals_object_should_return_false() | ||
{ | ||
var x = new MaterializedOnDemandBsonDocumentSerializer(); | ||
var y = new object(); | ||
|
||
var result = x.Equals(y); | ||
|
||
result.Should().Be(false); | ||
} | ||
|
||
[Fact] | ||
public void Equals_self_should_return_true() | ||
{ | ||
var x = new MaterializedOnDemandBsonDocumentSerializer(); | ||
|
||
var result = x.Equals(x); | ||
|
||
result.Should().Be(true); | ||
} | ||
|
||
[Fact] | ||
public void Equals_with_equal_fields_should_return_true() | ||
{ | ||
var x = new MaterializedOnDemandBsonDocumentSerializer(); | ||
var y = new MaterializedOnDemandBsonDocumentSerializer(); | ||
|
||
var result = x.Equals(y); | ||
|
||
result.Should().Be(true); | ||
} | ||
|
||
[Fact] | ||
public void GetHashCode_should_return_zero() | ||
{ | ||
var x = new MaterializedOnDemandBsonDocumentSerializer(); | ||
|
||
var result = x.GetHashCode(); | ||
|
||
result.Should().Be(0); | ||
} | ||
|
||
private class DerivedFromMaterializedOnDemandBsonDocumentSerializer : MaterializedOnDemandBsonDocumentSerializer | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.