コード例 #1
0
#pragma warning restore CS4014

        private static Dictionary <string, Functions.Models.Domains.Plugins.PluginPropertyValue[][]> CreateUserHoursProperty(int hours)
        {
            var hourValue = new Functions.Models.Domains.Plugins.PluginPropertyValue
            {
                Key   = "Hour",
                Value = hours
            };

            return(new Dictionary <string, Functions.Models.Domains.Plugins.PluginPropertyValue[][]>
            {
                { "OpenAir", new [] { new[] { hourValue } } }
            });
        }
コード例 #2
0
        public async Task OpenAirConnector_GetUnsubmittedTimesheetsForEndOfMonthAsync()
        {
            var options = new OpenAirOptions("http://localhost/", "MM", "K", "R", "P");
            var handler = new MockHttpMessageHandler()
                          .Set(CreateTimesheetXmlContent(
                                   (UserId: 3, new DateOnly(2020, 03, 23), Status: 'S', Hours: 40)))
                          .Set(CreateTimesheetXmlContent(
                                   (UserId: 2, new DateOnly(2020, 03, 30), Status: 'A', Hours: 16),
                                   (UserId: 1, new DateOnly(2020, 03, 30), Status: 'S', Hours: 40),
                                   (UserId: 4, new DateOnly(2020, 03, 30), Status: 'A', Hours: 12),
                                   (UserId: 3, new DateOnly(2020, 03, 30), Status: 'S', Hours: 8)));

            var client         = new OpenAirClient(() => handler, options);
            var storageService = Substitute.For <IStorageService>();
            var connector      = new OpenAirConnector(client, storageService);
            var user1          = CreateUser(1, "Test 1", "Q", "[email protected]");
            var user2          = CreateUser(2, "Test 2", "Q", "[email protected]");
            var user3          = CreateUser(3, "Test 3", "Q", "[email protected]");
            var user4          = CreateUser(4, "Test 4", "Q", "[email protected]");
            var date           = new DateTime(2020, 3, 31);

            var user4HourValue = new Functions.Models.Domains.Plugins.PluginPropertyValue
            {
                Key   = "Hour",
                Value = 30
            };

            user4.Properties = new Dictionary <string, Functions.Models.Domains.Plugins.PluginPropertyValue[][]>
            {
                { "OpenAir", new [] { new[] { user4HourValue } } }
            };

            storageService.GetAllActiveUsersAsync().ReturnsForAnyArgs(new[] { user1, user2, user3, user4 });

            // Act
            var timesheets = await connector.GetUnsubmittedTimesheetsAsync(date, date, TimesheetStates.Unsubmitted, "[email protected]", true, "Hour", null);

            Assert.AreEqual(1, timesheets.Count);
            Assert.AreEqual("Test 3", timesheets[0].UserName);
            Assert.AreEqual(8, timesheets[0].Total);
        }