Beispiel #1
0
        public void it_should_not_be_equal_if_they_are_different()
        {
            var a = new ObjectId(TestString);
            var b = new ObjectId(AnotherTestString);

            a.Should().NotBe(b);
            a.Equals(b).Should().BeFalse();
            (a != b).Should().BeTrue();
        }
Beispiel #2
0
        public void it_should_be_equal_if_they_are_the_same()
        {
            var a = new ObjectId(TestString);
            var b = new ObjectId(TestString);

            a.Should().Be(b);
            a.Equals(b).Should().BeTrue();
            (a == b).Should().BeTrue();
        }
        public void it_can_save_the_entity_so_that_it_is_queryable_by_key()
        {
            // Arrange
            var objId = new ObjectId();
            var fake = new MongoEntityFake { EntityId = objId, Name = "Test" };

            // Act
            _repo.Add(fake);
            var result = _repo.FindOneById(objId.ToString());

            // Assert
            result.Should().NotBeNull();
            result.Should().BeOfType<MongoEntityFake>();
        }
Beispiel #4
0
 /// <summary>Equalses the specified other.</summary>
 /// <param name="other">The other.</param>
 /// <returns>The equals.</returns>
 public bool Equals(ObjectId other)
 {
     return other != null && ToString() == other.ToString();
 }
Beispiel #5
0
        /// <summary>Tries to parse an ObjectId from a string.</summary>
        /// <param name="value">The string to parse.</param>
        /// <param name="id">The ObjectId.</param>
        /// <returns>The try parse result.</returns>
        public static bool TryParse(string value, out ObjectId id)
        {
            id = Empty;
            if (value == null || value.Length != 24) {
                return false;
            }

            try {
                id = new ObjectId(value);
                return true;
            }
            catch (FormatException) {
                return false;
            }
        }
Beispiel #6
0
 private static bool TestTryParse(string value, out ObjectId objectId)
 {
     return ObjectId.TryParse(value, out objectId);
 }
Beispiel #7
0
 public void it_should_be_empty_if_created_from_a_zeroed_string()
 {
     var objectId = new ObjectId(EmptyTestString);
     objectId.Should().Be(ObjectId.Empty);
 }