Here are the examples of the csharp api System.Threading.Tasks.Task.FromResult(WorkshopPlanning) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
19
Source : FinishMaintenanceJobCommandHandlerTests.cs
with Apache License 2.0
from EdwinVW
with Apache License 2.0
from EdwinVW
[Fact]
public async void Given_A_Non_Existing_Job_The_Handler_Should_Return_Null()
{
// arrange
DateTime date = DateTime.Today;
string workshopPlanningId = date.ToString("yyyy-MM-dd");
Guid jobId = Guid.NewGuid();
DateTime actualStartTime = date.AddHours(9);
DateTime actualEndTime = date.AddHours(12);
FinishMaintenanceJob command = new FinishMaintenanceJobCommandBuilder()
.WithJobId(jobId)
.WithActualStartTime(actualStartTime)
.WithActualEndTime(actualEndTime)
.Build();
Mock<IMessagePublisher> messagePublisherMock = new Mock<IMessagePublisher>();
Mock<IEventSourceRepository<WorkshopPlanning>> repoMock =
new Mock<IEventSourceRepository<WorkshopPlanning>>();
repoMock
.Setup(m => m.GetByIdAsync(It.Is<string>(p => p == workshopPlanningId)))
.Returns(Task.FromResult<WorkshopPlanning>(null));
FinishMaintenanceJobCommandHandler sut =
new FinishMaintenanceJobCommandHandler(messagePublisherMock.Object, repoMock.Object);
// act
var result = await sut.HandleCommandAsync(date, command);
// replacedert
messagePublisherMock.VerifyAll();
messagePublisherMock.VerifyNoOtherCalls();
repoMock.VerifyAll();
repoMock.VerifyNoOtherCalls();
replacedert.Null(result);
}
19
Source : PlanMaintenanceJobCommandHandlerTests.cs
with Apache License 2.0
from EdwinVW
with Apache License 2.0
from EdwinVW
[Fact]
public async void Given_A_Non_Existing_Job_The_Handler_Should_Return_Null()
{
// arrange
DateTime date = DateTime.Today;
string workshopPlanningId = date.ToString("yyy-MM-dd");
PlanMaintenanceJob command = new PlanMaintenanceJobCommandBuilder()
.Build();
Mock<IMessagePublisher> messagePublisherMock = new Mock<IMessagePublisher>();
Mock<IEventSourceRepository<WorkshopPlanning>> repoMock =
new Mock<IEventSourceRepository<WorkshopPlanning>>();
repoMock
.Setup(m => m.GetByIdAsync(It.Is<string>(p => p == workshopPlanningId)))
.Returns(Task.FromResult<WorkshopPlanning>(null));
repoMock
.Setup(m => m.SaveAsync(
It.Is<string>(p => p == workshopPlanningId),
It.Is<int>(p => p == 0),
It.Is<int>(p => p == 2),
It.Is<IEnumerable<Event>>(p =>
p.First().MessageType == "WorkshopPlanningCreated" &&
p.Last().MessageType == "MaintenanceJobPlanned")
))
.Returns(Task.CompletedTask);
messagePublisherMock
.Setup(m => m.PublishMessageAsync(
It.Is<string>(p => p == "WorkshopPlanningCreated"),
It.IsAny<object>(),
""))
.Returns(Task.CompletedTask);
messagePublisherMock
.Setup(m => m.PublishMessageAsync(
It.Is<string>(p => p == "MaintenanceJobPlanned"),
It.IsAny<object>(),
""))
.Returns(Task.CompletedTask);
PlanMaintenanceJobCommandHandler sut =
new PlanMaintenanceJobCommandHandler(messagePublisherMock.Object, repoMock.Object);
// act
WorkshopPlanning result = await sut.HandleCommandAsync(date, command);
// replacedert
messagePublisherMock.VerifyAll();
messagePublisherMock.VerifyNoOtherCalls();
repoMock.VerifyAll();
repoMock.VerifyNoOtherCalls();
replacedert.IsreplacedignableFrom<WorkshopPlanning>(result);
}