Пример #1
0
        public async Task GetEmployeeTimeDetails_Error_Wrong_Employee_Test()
        {
            //Arrange
            var(service, logger, mockFactory, mockHttpMessageHandler, config, sqlApi) = getService(ResponseContents.GetEmployeeTimeDetailsErrorWrongEmployeeResponse());

            var ex = await Assert.ThrowsAsync <ArgumentException>(async() => await service.GetEmployeeTimeDetails(1, 1234, new DateTime(2020, 10, 1), new DateTime(2020, 10, 30)));

            mockHttpMessageHandler.Protected().Verify(
                "SendAsync",
                Times.Exactly(1),
                ItExpr.Is <HttpRequestMessage>(req => req.CheckRequest(config.Endpoint, RequestContents.GetEmployeeTimeDetailsRequestContent(1, 1234, "1102020", "30102020"))),
                ItExpr.IsAny <CancellationToken>());
        }
Пример #2
0
        public async Task GetEmployeeTimeDetailsTest()
        {
            //Arrange
            var(service, logger, mockFactory, mockHttpMessageHandler, config, sqlApi) = getService(ResponseContents.GetEmployeeTimeDetailsResponse());

            var list = await service.GetEmployeeTimeDetails(1, 5555, new DateTime(2020, 10, 1), new DateTime(2020, 10, 30));

            list.Should().BeOfType <List <EmployeeTimeDetail> >();
            list.Count.Should().Be(30);

            list.First().GrossWorktime.Should().Be(TimeSpan.FromMinutes(519));
            list.First().TargetWorktime.Should().Be(TimeSpan.FromMinutes(492));
            list.First().NetWorktime.Should().Be(TimeSpan.FromMinutes(519));
            list.First().NetWorktimeDifference.Should().Be(TimeSpan.FromMinutes(27));

            list.Last().GrossWorktime.Should().Be(TimeSpan.FromMinutes(362));
            list.Last().TargetWorktime.Should().Be(TimeSpan.FromMinutes(342));
            list.Last().NetWorktime.Should().Be(TimeSpan.FromMinutes(362));
            list.Last().NetWorktimeDifference.Should().Be(TimeSpan.FromMinutes(20));

            mockHttpMessageHandler.Protected().Verify(
                "SendAsync",
                Times.Exactly(1),
                ItExpr.Is <HttpRequestMessage>(req => req.CheckRequest(config.Endpoint, RequestContents.GetEmployeeTimeDetailsRequestContent(1, 5555, "1102020", "30102020"))),
                ItExpr.IsAny <CancellationToken>());
        }