Skip to content

Commit

Permalink
Added tests to UpdateNameRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
pingu2k4 committed Jul 9, 2024
1 parent 3e1089c commit abaab4e
Showing 1 changed file with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using PinguApps.Appwrite.Shared.Requests;
using FluentValidation;
using PinguApps.Appwrite.Shared.Requests;

namespace PinguApps.Appwrite.Shared.Tests.Requests;
public class UpdateNameRequestTests
Expand Down Expand Up @@ -28,4 +29,68 @@ public void Properties_CanBeSet(string name)
// Assert
Assert.Equal(name, request.Name);
}

[Theory]
[InlineData("John")]
[InlineData("John Smith")]
public void IsValid_WithValidData_ReturnsTrue(string name)
{
// Arrange
var request = new UpdateNameRequest
{
Name = name
};

// Act
var isValid = request.IsValid();

// Assert
Assert.True(isValid);
}

[Theory]
[InlineData("")]
public void IsValid_WithInvalidData_ReturnsFalse(string name)
{
// Arrange
var request = new UpdateNameRequest
{
Name = name
};

// Act
var isValid = request.IsValid();

// Assert
Assert.False(isValid);
}

[Fact]
public void Validate_WithThrowOnFailuresTrue_ThrowsValidationExceptionOnFailure()
{
// Arrange
var request = new UpdateNameRequest
{
Name = ""
};

// Assert
Assert.Throws<ValidationException>(() => request.Validate(true));
}

[Fact]
public void Validate_WithThrowOnFailuresFalse_ReturnsInvalidResultOnFailure()
{
// Arrange
var request = new UpdateNameRequest
{
Name = ""
};

// Act
var result = request.Validate(false);

// Assert
Assert.False(result.IsValid);
}
}

0 comments on commit abaab4e

Please sign in to comment.