Commit 7fdf28d0 authored by Tomo Masakura's avatar Tomo Masakura

改行コードの違いで環境で受入テストが失敗するバグを修正

parent 7dd31a91
Pipeline #14826859 passed with stages
in 9 minutes and 51 seconds
using AcceptanceTest.Pages;
using System;
using AcceptanceTest.Pages;
using Xunit;
namespace AcceptanceTest
......@@ -31,17 +32,22 @@ namespace AcceptanceTest
[Fact]
public void TrimDescription()
{
var created = _target.Submit(new {Title = "T", Description = " a\r\n b \r\n"});
var created = _target.Submit(new {Title = "T", Description = " a\n b \n"});
Assert.Equal("a\r\n b", created.Description.Raw);
Assert.Equal(N("a\n b"), created.Description.Raw);
}
[Fact]
public void TrimSpecialCharactorsDescription()
{
var created = _target.Submit(new {Title = " T", Description = " a\r\n b  \r\n "});
var created = _target.Submit(new {Title = " T", Description = " a\n b  \n "});
Assert.Equal("a\r\n b", created.Description.Raw);
Assert.Equal(N("a\n b"), created.Description.Raw);
}
private static string N(string text)
{
return text?.Replace("\n", Environment.NewLine);
}
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ namespace Issues.Domains
public IssueDescription(string value)
{
_value = Trim(value);
_value = Normalize(value);
}
public override string ToString()
......
......@@ -8,7 +8,7 @@ namespace Issues.Domains
public IssueTitle(string value)
{
_value = Trim(value);
_value = Normalize(value);
}
public override string ToString()
......
using Xunit;
namespace Issues.Domains
{
public sealed class ValueObjectUtilTest
{
[Fact]
public void TrimSpaces()
{
var result = ValueObjectUtil.Normalize(" hello, world ");
Assert.Equal("hello, world", result);
}
[Fact]
public void TrimFullWidthSpaces()
{
var result = ValueObjectUtil.Normalize("  hello, world ");
Assert.Equal("hello, world", result);
}
[Fact]
public void TrimTabs()
{
var result = ValueObjectUtil.Normalize("\t\thello, world\t\t");
Assert.Equal("hello, world", result);
}
[Fact]
public void TrimCrLfs()
{
var result = ValueObjectUtil.Normalize("\r\n\rhello, world\r\n\r");
Assert.Equal("hello, world", result);
}
[Fact]
public void TrimCombine()
{
var result = ValueObjectUtil.Normalize("\r\n  \thello, world .\r\n\t  ");
Assert.Equal("hello, world .", result);
}
[Fact]
public void ConvertFromCrToLf()
{
var result = ValueObjectUtil.Normalize("[\r]");
Assert.Equal("[\n]", result);
}
[Fact]
public void ConvertFromLfToLf()
{
var result = ValueObjectUtil.Normalize("[\n]");
Assert.Equal("[\n]", result);
}
[Fact]
public void ConvertCombine()
{
var result = ValueObjectUtil.Normalize("\r\n[\r\n\n \r]\r\n");
Assert.Equal("[\n\n \n]", result);
}
}
}
\ No newline at end of file
......@@ -2,9 +2,12 @@
{
public static class ValueObjectUtil
{
public static string Trim(string value)
public static string Normalize(string value)
{
return value?.Trim();
return value?
.Trim()
.Replace("\r\n", "\n")
.Replace("\r", "\n");
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment