mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
[AC-1637] Moved expected values on unit tests to the arrange phase
This commit is contained in:
@ -16,6 +16,7 @@ public class HtmlEncodingStringConverterTests
|
|||||||
EncodedValue = "This is <b>bold</b>",
|
EncodedValue = "This is <b>bold</b>",
|
||||||
NonEncodedValue = "This is <b>bold</b>"
|
NonEncodedValue = "This is <b>bold</b>"
|
||||||
};
|
};
|
||||||
|
const string expectedJsonString = "{\"EncodedValue\":\"This is <b>bold</b>\",\"NonEncodedValue\":\"This is <b>bold</b>\"}";
|
||||||
|
|
||||||
// This is necessary to prevent the serializer from double encoding the string
|
// This is necessary to prevent the serializer from double encoding the string
|
||||||
var serializerOptions = new JsonSerializerOptions
|
var serializerOptions = new JsonSerializerOptions
|
||||||
@ -27,8 +28,7 @@ public class HtmlEncodingStringConverterTests
|
|||||||
var jsonString = JsonSerializer.Serialize(obj, serializerOptions);
|
var jsonString = JsonSerializer.Serialize(obj, serializerOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
const string expected = "{\"EncodedValue\":\"This is <b>bold</b>\",\"NonEncodedValue\":\"This is <b>bold</b>\"}";
|
Assert.Equal(expectedJsonString, jsonString);
|
||||||
Assert.Equal(expected, jsonString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -40,13 +40,13 @@ public class HtmlEncodingStringConverterTests
|
|||||||
EncodedValue = null,
|
EncodedValue = null,
|
||||||
NonEncodedValue = null
|
NonEncodedValue = null
|
||||||
};
|
};
|
||||||
|
const string expectedJsonString = "{\"EncodedValue\":null,\"NonEncodedValue\":null}";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jsonString = JsonSerializer.Serialize(obj);
|
var jsonString = JsonSerializer.Serialize(obj);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
const string expected = "{\"EncodedValue\":null,\"NonEncodedValue\":null}";
|
Assert.Equal(expectedJsonString, jsonString);
|
||||||
Assert.Equal(expected, jsonString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -54,13 +54,13 @@ public class HtmlEncodingStringConverterTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
const string json = "{\"EncodedValue\":\"This is <b>bold</b>\",\"NonEncodedValue\":\"This is <b>bold</b>\"}";
|
const string json = "{\"EncodedValue\":\"This is <b>bold</b>\",\"NonEncodedValue\":\"This is <b>bold</b>\"}";
|
||||||
|
const string expectedEncodedValue = "This is <b>bold</b>";
|
||||||
|
const string expectedNonEncodedValue = "This is <b>bold</b>";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var obj = JsonSerializer.Deserialize<HtmlEncodedString>(json);
|
var obj = JsonSerializer.Deserialize<HtmlEncodedString>(json);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
const string expectedEncodedValue = "This is <b>bold</b>";
|
|
||||||
const string expectedNonEncodedValue = "This is <b>bold</b>";
|
|
||||||
Assert.Equal(expectedEncodedValue, obj.EncodedValue);
|
Assert.Equal(expectedEncodedValue, obj.EncodedValue);
|
||||||
Assert.Equal(expectedNonEncodedValue, obj.NonEncodedValue);
|
Assert.Equal(expectedNonEncodedValue, obj.NonEncodedValue);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user