Exemple #1
0
        public Report Load(ToggleConfigurationSection toggle, string url, string password, string login, string authorName, DateTime startDate)
        {
            var issues = (List <LoggedIssue>)Issues;

            issues.Clear();

            var toggl      = new Toggl(toggle);
            var jiraServer = new JiraNew(url, password, login, authorName);
            var firstDay   = new DateTime(startDate.Year, startDate.Month, 1);
            var endOfMonth = new DateTime(startDate.Year, startDate.Month, DateTime.DaysInMonth(startDate.Year, startDate.Month));

            var togglSummary = toggl.GetSummary(toggle.Workspace, firstDay.AddMonths(-1), endOfMonth);
            var togglItems   = togglSummary.Groups.SelectMany(g => g.Items).Select(i => new TogglLoggedItem(i)).ToList();

            var togglGroups = togglItems.GroupBy(i => i.Issue).OrderByDescending(i => i.Key).ToList();
            var jiraResult  = jiraServer.GetIssues(togglGroups.Select(x => x.Key).Where(x => !string.IsNullOrWhiteSpace(x)).ToList());

            foreach (var group in togglGroups)
            {
                if (!string.IsNullOrEmpty(group.Key))
                {
                    JiraNew.Issue issue       = jiraResult.Issues.Single(x => x.Key == group.Key);
                    var           jiraWorkLog = issue.Fields.Worklog ?? jiraServer.GetWorkLog(group.Key);
                    jiraWorkLog.Items = jiraWorkLog.Items.Where(i => i.Author.Name == jiraServer.AuthorName).ToList();
                    var loggedIssue = new LoggedIssue(group.Key, group, jiraWorkLog, issue, jiraServer);
                    issues.Add(loggedIssue);
                }
            }

            return(this);
        }
Exemple #2
0
        public void TestLoadConfig()
        {
            IConfiguration configuration = InitConfiguration();

            ToggleConfigurationSection config = configuration.GetSection("ToggleConfiguration").Get <ToggleConfigurationSection>();

            Assert.NotNull(config);
        }
        public void ValidateIpAddressesTest()
        {
            ToggleConfigurationSection section = ConfigurationManager.GetSection("ToggleConfiguration") as ToggleConfigurationSection;

            ToggleElement toggle = section.Toggles[0];

            Assert.IsNotNull(toggle);

            Assert.AreEqual("CacheInheritableDatasource", toggle.Name);
            Assert.IsTrue(toggle.IpAddresses.Count > 0);

            Assert.AreEqual("127.0.0.1/28", toggle.IpAddresses[0].Value);
        }
        public void ValidateUsersTest()
        {
            ToggleConfigurationSection section = ConfigurationManager.GetSection("ToggleConfiguration") as ToggleConfigurationSection;

            ToggleElement toggle = section.Toggles[0];

            Assert.IsNotNull(toggle);

            Assert.AreEqual("CacheInheritableDatasource", toggle.Name);
            Assert.IsTrue(toggle.Users.Count > 0);

            Assert.AreEqual("abcd", toggle.Users[0].Name);
        }
Exemple #5
0
        public void ValidateIpAddressesTest()
        {
            IConfiguration configuration = InitConfiguration();

            ToggleConfigurationSection config = configuration.GetSection("ToggleConfiguration").Get <ToggleConfigurationSection>();

            ToggleElement toggle = config.toggles[0];

            Assert.IsNotNull(toggle);

            Assert.AreEqual("CacheInheritableDatasource", toggle.name);
            Assert.IsTrue(toggle.ipaddresses.Count > 0);

            Assert.AreEqual("127.0.0.1/28", toggle.ipaddresses[0].ipaddress.value);
        }
Exemple #6
0
        public void ValidateRolesTest()
        {
            IConfiguration configuration = InitConfiguration();

            ToggleConfigurationSection config = configuration.GetSection("ToggleConfiguration").Get <ToggleConfigurationSection>();

            ToggleElement toggle = config.toggles[0];

            Assert.IsNotNull(toggle);

            Assert.AreEqual("CacheInheritableDatasource", toggle.name);
            Assert.IsTrue(toggle.roles.Count > 0);

            Assert.AreEqual("Staff", toggle.roles[0].role.name);
        }
Exemple #7
0
 public AppConfigDataProvider(IConfiguration configuration)
 {
     ToggleConfigurations = configuration.GetSection("ToggleConfiguration").Get <ToggleConfigurationSection>();
     Initialise();
 }
        public void LoadSectionConfigTest()
        {
            ToggleConfigurationSection section = ConfigurationManager.GetSection("ToggleConfiguration") as ToggleConfigurationSection;

            Assert.IsNotNull(section);
        }
Exemple #9
0
 public Toggl(ToggleConfigurationSection setting)
 {
     this._username = setting.Login;
     this._password = setting.Password;
     this._url      = setting.Url;
 }