public void UpdateExpression_SetNullField_ShouldThrowArgumentNullExceptionWithFieldParamName() { // Arrange var updateExpression = new UpdateExpression <ITweet>(); var value = "Some value"; // Act + Assert var exception = Assert.Throws <ArgumentNullException>(() => updateExpression.Set <string>(null, value), @"ArgumentNullException should be thrown."); Assert.AreEqual("field", exception.ParamName, @"ParamName should be ""field""."); }
public void UpdateExpression_SetNullOrWhiteSpaceFieldName_ShouldThrowArgumentNullExceptionWithFieldNameParamName(string fieldName) { // Arrange var updateExpression = new UpdateExpression <ITweet>(); var value = "Some value"; // Act + Assert var exception = Assert.Throws <ArgumentNullException>(() => updateExpression.Set(fieldName, value), @"ArgumentNullException should be thrown."); Assert.AreEqual(nameof(fieldName), exception.ParamName, @"ParamName should be ""fieldName""."); }
public void UpdateExpression_SetValidStringFieldNameAndAnyValueObject_ShouldRegisterSingleSetCommandInUpdateCommands(string fieldName, object value) { // Arrange var updateExpression = new UpdateExpression <ITweet>(); // Act updateExpression.Set(fieldName, value); // Assert Assert.AreEqual(1, updateExpression.UpdateCommands.Count(), "Number of UpdateCommands should be 1."); var command = updateExpression.UpdateCommands.Single(); Assert.IsNotNull(command, "IUpdateCommand object should not be null."); Assert.AreEqual("Set", command.UpdateVerb, @"UpdateVerb of the IUpdateCommand should be ""Set""."); Assert.AreEqual(fieldName, command.FieldName, @"FieldName of the IUpdateCommand should be """ + fieldName + @"""."); Assert.AreSame(value, command.Value, @"Value of the IUpdateCommand should be """ + value + @"""."); }
public void UpdateExpression_SetValidExpressionForFavesFieldAndValidValue_ShouldRegisterSingleSetCommandInUpdateCommands() { // Arrange var updateExpression = new UpdateExpression <ITweet>(); var value = 123; // Act updateExpression.Set(t => t.Faves, value); // Assert Assert.AreEqual(1, updateExpression.UpdateCommands.Count(), "Number of UpdateCommands should be 1."); var command = updateExpression.UpdateCommands.Single(); Assert.IsNotNull(command, "IUpdateCommand object should not be null."); Assert.AreEqual("Set", command.UpdateVerb, @"UpdateVerb of the IUpdateCommand should be ""Set""."); Assert.AreEqual("Faves", command.FieldName, @"FieldName of the IUpdateCommand should be ""Faves""."); Assert.AreEqual(value, command.Value, @"Value of the IUpdateCommand should be """ + value + @"""."); }