U:调整所有代码格式
This commit is contained in:
1 parent
d133bacf55
commit
155b67e831
342 files changed
+9431
-9868
No files matched your search
@@ -125,10 +125,7 @@ public class ResultTests
|
||||
var executed = false;
|
||||
|
||||
// Act
|
||||
var result = Result.Try(() =>
|
||||
{
|
||||
executed = true;
|
||||
});
|
||||
var result = Result.Try(() => { executed = true; });
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result.IsSuccess);
|
||||
@@ -142,10 +139,7 @@ public class ResultTests
|
||||
public void Try_FailingAction_ReturnsFailure()
|
||||
{
|
||||
// Act
|
||||
var result = Result.Try(() =>
|
||||
{
|
||||
throw new InvalidOperationException("Operation failed");
|
||||
});
|
||||
var result = Result.Try(() => { throw new InvalidOperationException("Operation failed"); });
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result.IsFailure);
|
||||
@@ -188,10 +182,7 @@ public class ResultTests
|
||||
public async Task TryAsync_SuccessfulTask_ReturnsSuccess()
|
||||
{
|
||||
// Act
|
||||
var result = await Result.TryAsync(async () =>
|
||||
{
|
||||
await Task.Delay(10);
|
||||
});
|
||||
var result = await Result.TryAsync(async () => { await Task.Delay(10); });
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result.IsSuccess);
|
||||
@@ -310,10 +301,7 @@ public class ResultTests
|
||||
var result = Result.Failure<int>(exception);
|
||||
|
||||
// Act & Assert
|
||||
var thrown = Assert.ThrowsException<InvalidOperationException>(() =>
|
||||
{
|
||||
result.GetOrThrow();
|
||||
});
|
||||
var thrown = Assert.ThrowsException<InvalidOperationException>(() => { result.GetOrThrow(); });
|
||||
|
||||
Assert.AreSame(exception, thrown);
|
||||
}
|
||||
@@ -566,8 +554,8 @@ public class ResultTests
|
||||
|
||||
// Act
|
||||
var message = result.Match(
|
||||
onSuccess: value => $"Success: {value}",
|
||||
onFailure: (ex, msg) => $"Error: {msg}"
|
||||
value => $"Success: {value}",
|
||||
(ex, msg) => $"Error: {msg}"
|
||||
);
|
||||
|
||||
// Assert
|
||||
@@ -585,8 +573,8 @@ public class ResultTests
|
||||
|
||||
// Act
|
||||
var message = result.Match(
|
||||
onSuccess: value => $"Success: {value}",
|
||||
onFailure: (ex, msg) => $"Error: {msg}"
|
||||
value => $"Success: {value}",
|
||||
(ex, msg) => $"Error: {msg}"
|
||||
);
|
||||
|
||||
// Assert
|
||||
@@ -609,9 +597,9 @@ public class ResultTests
|
||||
|
||||
// Act: 使用 LINQ 查询语法
|
||||
var combined = from x in result1
|
||||
from y in result2
|
||||
where x > 0 && y > 0
|
||||
select x + y;
|
||||
from y in result2
|
||||
where x > 0 && y > 0
|
||||
select x + y;
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(combined.IsSuccess);
|
||||
@@ -630,8 +618,8 @@ public class ResultTests
|
||||
|
||||
// Act
|
||||
var combined = from x in result1
|
||||
from y in result2
|
||||
select x + y;
|
||||
from y in result2
|
||||
select x + y;
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(combined.IsFailure);
|
||||
@@ -877,4 +865,4 @@ public class ResultTests
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user