public void EntityReader_ShouldDeserializeEntity() { // Arrange _dateTimeWrapperMock.Setup(x => x.GetNow()).Returns(new DateTime(2010, 1, 1)); var reader = new EntityReader(_dateTimeWrapperMock.Object, _loggerMock.Object, _databaseMock.Object); // Act var result = reader.ReadEntity(_json); // Assert result.Should().BeEquivalentTo(_expectedEntity); }
public void EntityReader_ShouldLogDeserializationOfEntity() { // Arrange _dateTimeWrapperMock.Setup(x => x.GetNow()).Returns(new DateTime(2010, 1, 1)); var reader = new EntityReader(_dateTimeWrapperMock.Object, _loggerMock.Object, _databaseMock.Object); // Act reader.ReadEntity(_json); // Assert _loggerMock.Verify(x => x.WriteLine($"Entity deserialized. Id: {_expectedEntity.Id}, Name: {_expectedEntity.Name}, Type: {_expectedEntity.Type}, Timestamp: {_expectedEntity.Timestamp}")); }
public void EntityReader_ShouldPassValidation() { // Arrange _dateTimeWrapperMock.Setup(x => x.GetNow()).Returns(new DateTime(2010, 1, 1)); _databaseMock.Setup(x => x.IsValidationEnabled()).Returns(true); var reader = new EntityReader(_dateTimeWrapperMock.Object, _loggerMock.Object, _databaseMock.Object); // Act reader.ReadEntity(_json); // Assert _loggerMock.Verify(x => x.WriteLine($"Validation result: {true}")); }
public void EntityReader_ShouldDeserializeEntity() { // Arrange var expectedEntity = new Entity { Id = 1, Name = "Test Name", Type = EntityType.NotAwesomeType }; var reader = new EntityReader(); // Act var result = reader.ReadEntity(_json); // Assert Assert.AreEqual(expectedEntity.Id, result.Id); Assert.AreEqual(expectedEntity.Name, result.Name); Assert.AreEqual(expectedEntity.Type, result.Type); }