public void CheckEveryLanguageValueSet(RegionType type)
        {
            var unfound = new StringBuilder();

            foreach (LanguageKey val in Enum.GetValues(typeof(LanguageKey)))
            {
                var value = Language.Instance.GetMessageFromKey(val, type);
                if (value == $"#<{val.ToString()}>")
                {
                    unfound.Append("\nvalue ").Append(value).Append(" not defined");
                }
            }

            foreach (LogLanguageKey val in Enum.GetValues(typeof(LogLanguageKey)))
            {
                var value = LogLanguage.Instance.GetMessageFromKey(val, type.ToString());
                if (value == $"#<{val.ToString()}>")
                {
                    unfound.Append("\nvalue ").Append(value).Append(" not defined");
                }
            }


            if (unfound.Length != 0)
            {
                Assert.Fail(unfound.ToString());
            }
        }
Beispiel #2
0
        private string I18NTextFileName(string textfilename, RegionType region)
        {
            var regioncode = region.ToString().ToLower();

            regioncode = regioncode == "en" ? "uk" : regioncode == "cs" ? "cz" : regioncode;
            return(string.Format(textfilename, regioncode));
        }
Beispiel #3
0
        public string GetMessageFromKey(LanguageKey messageKey, RegionType culture)
        {
            var cult            = new CultureInfo(culture.ToString());
            var resourceMessage = (_manager != null)
                ? _manager.GetResourceSet(cult, true,
                                          cult.TwoLetterISOLanguageName == default(RegionType).ToString().ToLower(CultureInfo.CurrentCulture))
                                  ?.GetString(messageKey.ToString()) : string.Empty;

            return(!string.IsNullOrEmpty(resourceMessage) ? resourceMessage : $"#<{messageKey.ToString()}>");
        }
 public static Region ToRegion(this RegionType region)
 {
     return(region switch
     {
         RegionType.USEast2 => Region.USEast2,
         RegionType.USWest2 => Region.USWest2,
         RegionType.EuropeNorth => Region.EuropeNorth,
         RegionType.EuropeWest => Region.EuropeWest,
         RegionType.AsiaSouthEast => Region.AsiaSouthEast,
         _ => throw new Exception($"Unrecognized RegionType: {region.ToString()}")
     });
Beispiel #5
0
        private PasswordsMenuViewModel EnumPasswordsMenu()
        {
            PasswordsMenuViewModel model = new PasswordsMenuViewModel
            {
                MenuItems = new ObservableCollection <MenuItemViewModel>()
            };

            MenuItemViewModel item = new MenuItemViewModel("Логины", false, "")
            {
                MenuItems = new ObservableCollection <MenuItemViewModel>()
            };

            foreach (string str in (from s in Credentials select s.Login).Distinct <string>())
            {
                item.MenuItems.Add(new MenuItemViewModel(str, true, ""));
            }

            model.MenuItems.Add(item);


            MenuItemViewModel model3 = new MenuItemViewModel("Общие пароли", false, "")
            {
                MenuItems = new ObservableCollection <MenuItemViewModel>()
            };

            foreach (Credential credential in from p in Credentials
                     //where p.Region == RegionEnum.Общий
                     select p)
            {
                model3.MenuItems.Add(new MenuItemViewModel(credential.Password, true, $"{credential.Login} {credential.HostType}"));
            }
            model.MenuItems.Add(model3);

            for (int i = 1; i < 11; i++)
            {
                RegionEnum RegionType;
                Func <Credential, bool> c;
                if ((i != 10) && (i != 9))
                {
                    RegionType = (RegionEnum)i;
                    MenuItemViewModel model4 = new MenuItemViewModel(RegionType.ToString(), false, "")
                    {
                        MenuItems = new ObservableCollection <MenuItemViewModel>()
                    };
                    foreach (Credential credential2 in Credentials.Where((c = p => p.Region == RegionType)))
                    {
                        model4.MenuItems.Add(new MenuItemViewModel(credential2.Password, true, $"{credential2.Login} {credential2.HostType}"));
                    }
                    model.MenuItems.Add(model4);
                }
            }
            model.MenuItems.Add(new MenuItemViewModel("Отмена", false, ""));
            return(model);
        }
Beispiel #6
0
        public void CheckEveryLanguageAreUsefull(RegionType type)
        {
            var unfound   = new StringBuilder();
            var values    = Enum.GetValues(typeof(LanguageKey)).OfType <LanguageKey>().Select(s => s.ToString()).ToList();
            var logvalues = Enum.GetValues(typeof(LogLanguageKey)).OfType <LogLanguageKey>().Select(s => s.ToString())
                            .ToList();

            foreach (var resourceKey in LogLanguage.Instance.GetRessourceSet(type.ToString()) !.Cast <DictionaryEntry?>().Select(entry => entry?.Key.ToString() ?? "").Where(resourceKey => !values.Contains(resourceKey) && !logvalues.Contains(resourceKey)))
            {
                unfound.Append("key ").Append(resourceKey).Append(" is useless\n");
            }

            if (!string.IsNullOrEmpty(unfound.ToString()))
            {
                Assert.Fail(unfound.ToString());
            }
        }
Beispiel #7
0
        public void CheckEveryLanguageValueSet(RegionType type)
        {
            string unfound = string.Empty;

            foreach (LogLanguageKey val in Enum.GetValues(typeof(LogLanguageKey)))
            {
                string value = LogLanguage.Instance.GetMessageFromKey(val, type.ToString());
                if (value == $"#<{val.ToString()}>")
                {
                    unfound += $"\nvalue {value} not defined";
                }
            }
            if (!string.IsNullOrEmpty(unfound))
            {
                Assert.Fail(unfound);
            }
        }
Beispiel #8
0
        public void CheckEveryLanguageAreUsefull(RegionType type)
        {
            string unfound = string.Empty;
            var    values  = Enum.GetValues(typeof(LogLanguageKey)).OfType <LogLanguageKey>().Select(s => s.ToString());

            foreach (DictionaryEntry entry in LogLanguage.Instance.GetRessourceSet(type.ToString()))
            {
                string resourceKey = entry.Key.ToString();
                if (!values.Contains(resourceKey))
                {
                    unfound += $"key {resourceKey} is useless\n";
                }
            }
            if (!string.IsNullOrEmpty(unfound))
            {
                Assert.Fail(unfound);
            }
        }
        static void UpdateRegion(RegionType regionType)
        {
            int        n = CurrentRegionTypes.Count;
            RegionType lastRegionType = CurrentRegionTypes[n - 1];

            if (regionType == lastRegionType)
            {
                return;
            }
            if (lastRegionType != RegionType.None && CurrentIndent != n)
            {
                File.WriteLine(Indent1 + "#endregion" + Environment.NewLine);
                CurrentRegionTypes.RemoveAt(n - 1);
            }
            if (regionType != RegionType.None)
            {
                File.WriteLine(Indent1 + "#region " + regionType.ToString() + Environment.NewLine);
                CurrentRegionTypes.Add(regionType);
            }
        }
Beispiel #10
0
        private Task <bool> SendHello(RegionType type)
        {
            var connHeader = new ConnectionHeader
            {
                UserInfo = new UserInformation
                {
                    EffectiveUser = EffectiveUser
                },
                ServiceName = type.ToString()
            };
            var data   = connHeader.ToByteArray();
            var header = "HBas\x00\x50".ToUtf8Bytes(); // \x50 = Simple Auth.
            var buf    = new byte[header.Length + 4 + data.Length];

            header.CopyTo(buf, 0);
            var dataLenBig = EndianBitConverter.BigEndian.GetBytes((uint)data.Length);

            dataLenBig.CopyTo(buf, 6);
            data.CopyTo(buf, header.Length + 4);
            return(Write(buf, new CancellationToken()));
        }
Beispiel #11
0
 /// <summary>
 /// Gets the type of the readable region.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <returns></returns>
 public static string GetReadableRegionType(RegionType type)
 {
     switch (type)
     {
         case RegionType.City:
         case RegionType.County:
         case RegionType.Prefecture:
         case RegionType.Province:
         case RegionType.Region:
         case RegionType.State:
             return type.ToString();
         case RegionType.AdministrativeDivision:
             return "Administrative Division";
         case RegionType.CityRegion:
             return "City/Region";
         case RegionType.ConstituentCountry:
             return "Constituent Country";
         case RegionType.StateTerritory:
             return "State/Territory";
         default:
             throw new NotImplementedException();
     }
 }
Beispiel #12
0
        public async Task AllAsyncShould_ReturnsIssueWithCorrectModel(bool isApproved, int rowsCount, int page, RegionType region, IssueType issueType, string sortType)
        {
            //Arrange
            var issue       = CreateIssue(true, RegionType.Central, IssueType.DangerousTrees);
            var secondIssue = CreateIssue(true, RegionType.Central, IssueType.Sidewalks);
            var thirdIssue  = CreateIssue(true, RegionType.Western, IssueType.DangerousBuildings);

            await this.Db.AddRangeAsync(issue, secondIssue, thirdIssue);

            var notApprovedIssue       = CreateIssue(false, RegionType.Central, IssueType.DangerousBuildings);
            var secondNotApprovedIssue = CreateIssue(false, RegionType.Central, IssueType.DangerousBuildings);
            var thirdNotApprovedIssue  = CreateIssue(false, RegionType.South, IssueType.DangerousBuildings);

            await this.Db.AddRangeAsync(notApprovedIssue, secondNotApprovedIssue, thirdNotApprovedIssue);

            await this.Db.SaveChangesAsync();

            //TODO: rearrange test - now issueService has more parameters
            var service = new IssueService(this.Db, null);

            //Act
            (var pagesCount, var issues) = await service
                                           .AllAsync <IssuesListingModel>(isApproved, rowsCount, page, region.ToString(), issueType.ToString(), sortType);

            var result = issues.ToList();

            var expectedCount = await this.Db.UrbanIssues.Where(i => i.IsApproved == isApproved && i.Region == region && i.Type == issueType)
                                .Skip((page - 1) * IssuesOnRow * rowsCount)
                                .Take(IssuesOnRow).CountAsync();

            var dbIssues = this.Db.UrbanIssues.ToList();

            //Assert
            result.Should().BeOfType <List <IssuesListingModel> >();

            result.Should().HaveCount(expectedCount);

            result.Should().NotContain(i => i.IsApproved != isApproved);

            if (region != RegionType.All)
            {
                var issuesToNotContain = dbIssues.Where(x => x.Region != region);
                result.Should().NotContain(issuesToNotContain);
            }

            var issuesWithAnotherTypes = dbIssues.Where(x => x.Type != issueType).ToList();

            result.Should().NotContain(issuesWithAnotherTypes);

            if (sortType == null || sortType == SortDesc)
            {
                result.Should().BeInDescendingOrder(i => i.PublishedOn);
            }
            else
            {
                result.Should().BeInAscendingOrder(i => i.PublishedOn);
            }
        }
 public void MVN_PLN_goto(RegionType regionType, string goalRegion)
 {
     this.justinaCmdAndResp[(int)JustinaCommands.MVN_PLN_goto].IsResponseReceived = false;
     this.justinaCmdAndResp[(int)JustinaCommands.MVN_PLN_goto].Command.Parameters = regionType.ToString().ToLower() + " " + goalRegion;
     this.SendCommand(this.justinaCmdAndResp[(int)JustinaCommands.MVN_PLN_goto].Command);
 }
Beispiel #14
0
 public Realm(RegionType region)
 {
     Name = region.ToString();
     Region = region;
 }
Beispiel #15
0
 private Boolean CompareRegion(String regionName, RegionType region)
 {
     return(region.ToString().Contains(regionName));
 }
Beispiel #16
0
 public Realm(RegionType region)
 {
     Name   = region.ToString();
     Region = region;
 }
 public void MVN_PLN_goto(RegionType regionType, string goalRegion)
 {
     this.justinaCmdAndResp[(int)JustinaCommands.MVN_PLN_goto].IsResponseReceived = false;
     this.justinaCmdAndResp[(int)JustinaCommands.MVN_PLN_goto].Command.Parameters = regionType.ToString().ToLower() + " " + goalRegion;
     this.SendCommand(this.justinaCmdAndResp[(int)JustinaCommands.MVN_PLN_goto].Command);
 }
 private Boolean CompareRegion(String regionName, RegionType region)
 {
     return region.ToString().Contains(regionName);
 }