Пример #1
0
        public void GetHashCode_HasFewCollisions()
        {
            // generate list of names
            List <string> names = new();
            {
                Random random     = new();
                string characters = "abcdefghijklmnopqrstuvwxyz1234567890/";

                while (names.Count < 1000)
                {
                    char[] name = new char[random.Next(5, 20)];
                    for (int i = 0; i < name.Length; i++)
                    {
                        name[i] = characters[random.Next(0, characters.Length)];
                    }

                    names.Add(new string(name));
                }
            }

            // get distinct hash codes
            HashSet <int> hashCodes = new();

            foreach (string name in names)
            {
                hashCodes.Add(AssetName.Parse(name, _ => null).GetHashCode());
            }

            // assert a collision frequency under 0.1%
            float collisionFrequency = 1 - (hashCodes.Count / (names.Count * 1f));

            collisionFrequency.Should().BeLessOrEqualTo(0.001f, "hash codes should be relatively distinct with a collision rate under 0.1% for a small sample set");
        }
Пример #2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (AvatarCustomizationClickId != 0)
            {
                hash ^= AvatarCustomizationClickId.GetHashCode();
            }
            if (AssetName.Length != 0)
            {
                hash ^= AssetName.GetHashCode();
            }
            if (Sku.Length != 0)
            {
                hash ^= Sku.GetHashCode();
            }
            if (HasEnoughCoins != false)
            {
                hash ^= HasEnoughCoins.GetHashCode();
            }
            if (GroupName.Length != 0)
            {
                hash ^= GroupName.GetHashCode();
            }
            if (ColorChoiceId.Length != 0)
            {
                hash ^= ColorChoiceId.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #3
0
        public bool StartsWith_SimpleCases(string mainAssetName, string prefix)
        {
            // arrange
            mainAssetName = PathUtilities.NormalizeAssetName(mainAssetName);

            // act
            AssetName name = AssetName.Parse(mainAssetName, _ => null);

            // assert value is the same for any combination of options
            bool result = name.StartsWith(prefix, true, true);

            foreach (bool allowPartialWord in new[] { true, false })
            {
                foreach (bool allowSubfolder in new[] { true, true })
                {
                    if (allowPartialWord && allowSubfolder)
                    {
                        continue;
                    }

                    name.StartsWith(prefix, allowPartialWord, allowSubfolder)
                    .Should().Be(result, $"the value returned for options ({nameof(allowPartialWord)}: {allowPartialWord}, {nameof(allowSubfolder)}: {allowSubfolder}) should match the base case");
                }
            }

            // assert value
            return(result);
        }
Пример #4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Enabled != false)
            {
                hash ^= Enabled.GetHashCode();
            }
            if (AvatarType != 0)
            {
                hash ^= AvatarType.GetHashCode();
            }
            hash ^= slot_.GetHashCode();
            if (BundleName.Length != 0)
            {
                hash ^= BundleName.GetHashCode();
            }
            if (AssetName.Length != 0)
            {
                hash ^= AssetName.GetHashCode();
            }
            if (GroupName.Length != 0)
            {
                hash ^= GroupName.GetHashCode();
            }
            if (SortOrder != 0)
            {
                hash ^= SortOrder.GetHashCode();
            }
            if (UnlockType != 0)
            {
                hash ^= UnlockType.GetHashCode();
            }
            hash ^= promoType_.GetHashCode();
            if (UnlockBadgeType != 0)
            {
                hash ^= UnlockBadgeType.GetHashCode();
            }
            if (IapSku.Length != 0)
            {
                hash ^= IapSku.GetHashCode();
            }
            if (UnlockBadgeLevel != 0)
            {
                hash ^= UnlockBadgeLevel.GetHashCode();
            }
            if (IconName.Length != 0)
            {
                hash ^= IconName.GetHashCode();
            }
            if (UnlockPlayerLevel != 0)
            {
                hash ^= UnlockPlayerLevel.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
 /// <summary>Snippet for GetAsset</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetAssetResourceNames()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     AssetName resourceName = AssetName.FromCustomerAsset("[CUSTOMER]", "[ASSET]");
     // Make the request
     Asset response = assetServiceClient.GetAsset(resourceName);
 }
Пример #6
0
 public void NewNameContainsCorrectNumberOfDigits()
 {
     // Test default constructor includes the proper # of digits.
     // Verify that the max # of digits is capped at int.max.
     for (int i = 1; i < 1000; i++)
     {
         Assert.True(Regex.IsMatch(AssetName.NewName(i), $@"^[a-z]*_[a-z]*_\d{{{i}}}$"));
     }
 }
Пример #7
0
        public void NewNameDoesNotContainDigitsByDefault()
        {
            // Test default constructor does not include digits
            Assert.True(Regex.IsMatch(AssetName.NewName(), "^[a-z]*_[a-z]*$"));

            // Test any number less than or equal to 0 will result in a non-digit string.
            Assert.True(Regex.IsMatch(AssetName.NewName(-100), "^[a-z]*_[a-z]*$"));
            Assert.True(Regex.IsMatch(AssetName.NewName(0), "^[a-z]*_[a-z]*$"));
        }
        /// <summary>Snippet for GetAssetAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetAssetResourceNamesAsync()
        {
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            AssetName resourceName = AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]");
            // Make the request
            Asset response = await assetServiceClient.GetAssetAsync(resourceName);
        }
Пример #9
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = FrameWidth;
         hashCode = (hashCode * 397) ^ FrameHeight;
         hashCode = (hashCode * 397) ^ (AssetName != null ? AssetName.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #10
0
        /// <summary>
        /// [Private API]出金アカウントを取得します。
        /// </summary>
        /// <param name="asset">通貨名</param>
        /// <returns>出金アカウント情報</returns>
        /// <exception cref="BitbankDotNetException">APIリクエストでエラーが発生しました。</exception>
        public async Task <WithdrawalAccount[]> GetWithdrawalAccountsAsync(AssetName asset)
        {
            var query = HttpUtility.ParseQueryString(string.Empty);

            query["asset"] = asset.GetEnumMemberValue();

            var result = await GetWithdrawalAccountsAsync(query.ToString()).ConfigureAwait(false);

            return(result.Accounts);
        }
Пример #11
0
        /// <summary>
        /// [Private API]出金リクエストを行います。
        /// </summary>
        /// <param name="asset">アセット名</param>
        /// <param name="amount">引き出し量</param>
        /// <param name="uuid">出金アカウントのUUID</param>
        /// <returns>出金情報</returns>
        /// <exception cref="BitbankDotNetException">APIリクエストでエラーが発生しました。</exception>
        public Task <Withdrawal> RequestWithdrawalAsync(AssetName asset, decimal amount, string uuid)
        {
            var body = new WithdrawalBody
            {
                Asset  = asset,
                Amount = amount,
                Uuid   = uuid
            };

            return(PrivateApiPostAsync <Withdrawal, WithdrawalBody>(RequestWithdrawalPath, body));
        }
Пример #12
0
        public bool IsEquivalentTo_Name(string mainAssetName, string otherAssetName)
        {
            // arrange
            mainAssetName = PathUtilities.NormalizeAssetName(mainAssetName);

            // act
            AssetName name = AssetName.Parse(mainAssetName, _ => LocalizedContentManager.LanguageCode.fr);

            // assert
            return(name.IsEquivalentTo(otherAssetName));
        }
 /// <summary>Snippet for GetAsset</summary>
 public void GetAssetResourceNames()
 {
     // Snippet: GetAsset(AssetName, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     AssetName resourceName = AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]");
     // Make the request
     Asset response = assetServiceClient.GetAsset(resourceName);
     // End snippet
 }
 /// <summary>Snippet for GetAsset</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetAssetRequestObject()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     GetAssetRequest request = new GetAssetRequest
     {
         ResourceNameAsAssetName = AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]"),
     };
     // Make the request
     Asset response = assetServiceClient.GetAsset(request);
 }
        /// <summary>Snippet for GetAssetAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetAssetRequestObjectAsync()
        {
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetAssetRequest request = new GetAssetRequest
            {
                ResourceNameAsAssetName = AssetName.FromCustomerAsset("[CUSTOMER]", "[ASSET]"),
            };
            // Make the request
            Asset response = await assetServiceClient.GetAssetAsync(request);
        }
Пример #16
0
        public void GetHashCode_IsCaseInsensitive()
        {
            // arrange
            string left  = "data/ACHIEVEMENTS";
            string right = "DATA/achievements";

            // act
            int leftHash  = AssetName.Parse(left, _ => null).GetHashCode();
            int rightHash = AssetName.Parse(right, _ => null).GetHashCode();

            // assert
            leftHash.Should().Be(rightHash, "two asset names which differ only by capitalization should produce the same hash code");
        }
Пример #17
0
        /// <summary>
        /// [Private API]出金リクエストを行います。
        /// </summary>
        /// <param name="asset">アセット名</param>
        /// <param name="amount">引き出し量</param>
        /// <param name="uuid">出金アカウントのUUID</param>
        /// <param name="otpToken">二段階認証トークン</param>
        /// <param name="smsToken">SMS認証トークン</param>
        /// <returns>出金情報</returns>
        /// <exception cref="BitbankDotNetException">APIリクエストでエラーが発生しました。</exception>
        public Task <Withdrawal> RequestWithdrawalAsync(AssetName asset, decimal amount, string uuid, int?otpToken, int?smsToken)
        {
            var body = new WithdrawalBody
            {
                Asset    = asset,
                Amount   = amount,
                Uuid     = uuid,
                OtpToken = otpToken,
                SmsToken = smsToken
            };

            return(PrivateApiPostAsync <Withdrawal, WithdrawalBody>(RequestWithdrawalPath, body));
        }
        /// <summary>Snippet for GetAssetAsync</summary>
        public async Task GetAssetResourceNamesAsync()
        {
            // Snippet: GetAssetAsync(AssetName, CallSettings)
            // Additional: GetAssetAsync(AssetName, CancellationToken)
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            AssetName resourceName = AssetName.FromCustomerAsset("[CUSTOMER]", "[ASSET]");
            // Make the request
            Asset response = await assetServiceClient.GetAssetAsync(resourceName);

            // End snippet
        }
Пример #19
0
        int DumpCommunicationText()
        {
            HashSet <string> AllJPText = new HashSet <string>();

            foreach (var AssetBundleName in CommonLib.GetAssetBundleNameListFromPath("communication"))
            {
                if (AssetBundleName.Contains("hit_"))
                {
                    continue;
                }

                foreach (var AssetName in AssetBundleCheck.GetAllAssetName(AssetBundleName))
                {
                    var Asset = ManualLoadAsset <ExcelData>(AssetBundleName, AssetName, "abdata");

                    HashSet <string> JPText = new HashSet <string>();

                    foreach (var param in Asset.list)
                    {
                        if (15 <= param.list.Count && !param.list[15].IsNullOrEmpty() && param.list[15] != "テキスト")
                        {
                            AllJPText.Add($"//{param.list[15]}=");
                            JPText.Add($"//{param.list[15]}=");
                        }
                    }

                    if (JPText.Count > 0)
                    {
                        string FolderPath = Path.Combine(Paths.GameRootPath, "TextDump");
                        FolderPath = Path.Combine(FolderPath, AssetBundleName.Replace(".unity3d", ""));
                        FolderPath = Path.Combine(FolderPath, AssetName.Replace(".asset", ""));
                        FolderPath = FolderPath.Replace('/', '\\');
                        if (!Directory.Exists(FolderPath))
                        {
                            Directory.CreateDirectory(FolderPath);
                        }

                        string FilePath = Path.Combine(FolderPath, "translation.txt");
                        if (File.Exists(FilePath))
                        {
                            File.Delete(FilePath);
                        }

                        File.WriteAllLines(FilePath, JPText.ToArray());
                    }
                }
            }
            Logger.Log(LogLevel.Info, $"Total Communication unique lines:{AllJPText.Count}");
            return(AllJPText.Count);
        }
Пример #20
0
 public override bool IsDone()
 {
     if (Request == null && string.IsNullOrEmpty(DownloadingError) == false)
     {
         //Debug.LogError(DownloadingError);
         return(true);
     }
     if (Request != null)
     {
         if (string.IsNullOrEmpty(AssetName) || AssetName.Equals("NULL") || AssetName.Equals("null"))
         {
             return(true);
         }
     }
     return(Request != null && Request.isDone);
 }
Пример #21
0
        int DumpScenarioText()
        {
            HashSet <string> AllJPText = new HashSet <string>();

            foreach (var AssetBundleName in CommonLib.GetAssetBundleNameListFromPath("adv/scenario", true))
            {
                foreach (var AssetName in AssetBundleCheck.GetAllAssetName(AssetBundleName)) //.Where(x => x.StartsWith("personality_voice_"))
                {
                    var Asset = ManualLoadAsset <ADV.ScenarioData>(AssetBundleName, AssetName, "abdata");

                    HashSet <string> JPText = new HashSet <string>();
                    foreach (var param in Asset.list)
                    {
                        if (param.Command == ADV.Command.Text)
                        {
                            if (1 <= param.Args.Length && !param.Args[1].IsNullOrEmpty())
                            {
                                AllJPText.Add($"//{param.Args[1]}=");
                                JPText.Add($"//{param.Args[1]}=");
                            }
                        }
                    }

                    if (JPText.Count > 0)
                    {
                        string FolderPath = Path.Combine(Paths.GameRootPath, "TextDump");
                        FolderPath = Path.Combine(FolderPath, AssetBundleName.Replace(".unity3d", ""));
                        FolderPath = Path.Combine(FolderPath, AssetName.Replace(".asset", ""));
                        FolderPath = FolderPath.Replace('/', '\\');
                        if (!Directory.Exists(FolderPath))
                        {
                            Directory.CreateDirectory(FolderPath);
                        }

                        string FilePath = Path.Combine(FolderPath, "translation.txt");
                        if (File.Exists(FilePath))
                        {
                            File.Delete(FilePath);
                        }

                        File.WriteAllLines(FilePath, JPText.ToArray());
                    }
                }
            }
            Logger.Log(LogLevel.Info, $"Total Scenario unique lines:{AllJPText.Count}");
            return(AllJPText.Count);
        }
Пример #22
0
        public bool StartsWith_Subfolder(string mainAssetName, string otherAssetName, bool allowSubfolder)
        {
            // arrange
            mainAssetName = PathUtilities.NormalizeAssetName(mainAssetName);

            // act
            AssetName name = AssetName.Parse(mainAssetName, _ => null);

            // assert value is the same for any combination of options
            bool result = name.StartsWith(otherAssetName, allowPartialWord: true, allowSubfolder: allowSubfolder);

            name.StartsWith(otherAssetName, allowPartialWord: false, allowSubfolder: allowSubfolder)
            .Should().Be(result, "specifying allowPartialWord should have no effect for these inputs");

            // assert value
            return(result);
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (AssetName.Length != 0)
            {
                hash ^= AssetName.GetHashCode();
            }
            if (TotalLoadTime != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(TotalLoadTime);
            }
            hash ^= bundleName_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #24
0
        public void Constructor_Valid(string name, string expectedBaseName, string expectedLocale, LocalizedContentManager.LanguageCode?expectedLanguageCode)
        {
            // arrange
            name = PathUtilities.NormalizeAssetName(name);

            // act
            string     calledWithLocale = null;
            IAssetName assetName        = AssetName.Parse(name, parseLocale: locale => expectedLanguageCode);

            // assert
            assetName.Name.Should()
            .NotBeNull()
            .And.Be(name.Replace("\\", "/"));
            assetName.BaseName.Should()
            .NotBeNull()
            .And.Be(expectedBaseName);
            assetName.LocaleCode.Should()
            .Be(expectedLocale);
            assetName.LanguageCode.Should()
            .Be(expectedLanguageCode);
        }
Пример #25
0
        public async Task GetAssetAsync()
        {
            Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict);
            GetAssetRequest expectedRequest = new GetAssetRequest
            {
                ResourceName = new AssetName("[CUSTOMER]", "[ASSET]").ToString(),
            };
            Asset expectedResponse = new Asset
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetAssetAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Asset>(Task.FromResult(expectedResponse), null, null, null, null));
            AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null);
            string             formattedResourceName = new AssetName("[CUSTOMER]", "[ASSET]").ToString();
            Asset response = await client.GetAssetAsync(formattedResourceName);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #26
0
 public int GetHashCode()
 {
     unchecked
     {
         return(((BundleName != null ? BundleName.GetHashCode() : 0) * 397) ^ (AssetName != null ? AssetName.GetHashCode() : 0));
     }
 }
Пример #27
0
 public LifoAsset(AssetName name) : base(name)
 {
 }
Пример #28
0
 public void AddToAssetNames(AssetName assetName)
 {
     base.AddObject("AssetNames", assetName);
 }
Пример #29
0
 public static AssetName CreateAssetName(long assetNameID, string name)
 {
     AssetName assetName = new AssetName();
     assetName.AssetNameID = assetNameID;
     assetName.Name = name;
     return assetName;
 }
Пример #30
0
        int DumpHText()
        {
            HashSet <string> AllJPText = new HashSet <string>();

            foreach (var AssetBundleName in CommonLib.GetAssetBundleNameListFromPath("h/list/"))
            {
                foreach (var AssetName in AssetBundleCheck.GetAllAssetName(AssetBundleName).Where(x => x.StartsWith("personality_voice_")))
                {
                    if (AssetName.EndsWith(".txt"))
                    {
                        var Asset = ManualLoadAsset <TextAsset>(AssetBundleName, AssetName, "abdata");

                        HashSet <string> JPText = new HashSet <string>();
                        string[]         Rows   = Asset.text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
                        for (int i = 0; i < Rows.Count(); i++)
                        {
                            string[] Cells = Rows[i].Split('\t');
                            if (4 < Cells.Length && !Cells[4].IsNullOrEmpty())
                            {
                                AllJPText.Add($"//{Cells[4]}=");
                                JPText.Add($"//{Cells[4]}=");
                            }
                            if (27 < Cells.Length && !Cells[27].IsNullOrEmpty())
                            {
                                AllJPText.Add($"//{Cells[27]}=");
                                JPText.Add($"//{Cells[27]}=");
                            }
                            if (50 < Cells.Length && !Cells[50].IsNullOrEmpty())
                            {
                                AllJPText.Add($"//{Cells[50]}=");
                                JPText.Add($"//{Cells[50]}=");
                            }
                            if (73 < Cells.Length && !Cells[73].IsNullOrEmpty())
                            {
                                AllJPText.Add($"//{Cells[73]}=");
                                JPText.Add($"//{Cells[73]}=");
                            }
                        }

                        if (JPText.Count > 0)
                        {
                            string FolderPath = Path.Combine(Paths.GameRootPath, "TextDump");
                            FolderPath = Path.Combine(FolderPath, AssetBundleName.Replace(".unity3d", ""));
                            FolderPath = Path.Combine(FolderPath, AssetName.Replace(".txt", ""));
                            FolderPath = FolderPath.Replace('/', '\\');
                            if (!Directory.Exists(FolderPath))
                            {
                                Directory.CreateDirectory(FolderPath);
                            }

                            string FilePath = Path.Combine(FolderPath, "translation.txt");
                            if (File.Exists(FilePath))
                            {
                                File.Delete(FilePath);
                            }

                            File.WriteAllLines(FilePath, JPText.ToArray());
                        }
                    }
                }
            }
            Logger.Log(LogLevel.Info, $"Total H-Scene unique lines:{AllJPText.Count}");
            return(AllJPText.Count);
        }
Пример #31
0
 public static void DebugLog(AssetName assetName, string message)
 {
     Debug.Log("[EZ][" + assetName + "] " + message);
 }
Пример #32
0
 // heading - cols
 public override string Panel() => $"{Category.PadRight(15)}{AssetName.PadRight(8)}{Model.PadRight(8)}{Purdate.ToShortDateString().PadRight(8)}\t{Price}";