Esempio n. 1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (FolderId.Length != 0)
            {
                hash ^= FolderId.GetHashCode();
            }
            if (createdAt_ != null)
            {
                hash ^= CreatedAt.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            hash ^= Labels.GetHashCode();
            if (Status != global::Yandex.Cloud.Kms.V1.SymmetricKey.Types.Status.Unspecified)
            {
                hash ^= Status.GetHashCode();
            }
            if (primaryVersion_ != null)
            {
                hash ^= PrimaryVersion.GetHashCode();
            }
            if (DefaultAlgorithm != global::Yandex.Cloud.Kms.V1.SymmetricAlgorithm.Unspecified)
            {
                hash ^= DefaultAlgorithm.GetHashCode();
            }
            if (rotatedAt_ != null)
            {
                hash ^= RotatedAt.GetHashCode();
            }
            if (rotationPeriod_ != null)
            {
                hash ^= RotationPeriod.GetHashCode();
            }
            if (DeletionProtection != false)
            {
                hash ^= DeletionProtection.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 2
0
        public async Task SizeTest(int size, int?seed)
        {
            var config = new Mock <IConfiguration>();

            config.SetupGet(x => x.Size).Returns(size);
            config.SetupGet(x => x.Seed).Returns(seed);
            config.SetupGet(x => x.Persistence).Returns(1);

            var algorithm = new DefaultAlgorithm(config.Object);

            var result = await algorithm.Generate();

            Assert.Equal(size, result.Length);
            Assert.Equal(size, result[0].Length);
        }
        private void FillKeywordDetails(ref KeywordQuickSearch C, SearchVideos.RootObject R)
        {
            C.Details.AvgViewCount     = (int)C.Details.Videos.Average(x => x.ViewCount);
            C.Details.HighestViewCount = C.Details.Videos.Max(x => x.ViewCount);
            C.Details.LowestViewCount  = C.Details.Videos.Min(x => x.ViewCount);

            int old = C.Details.Videos.Where(x => DateTime.Now.Year - x.UploadedDate.Year == 1).Count();

            C.Details.OldVideos = old;
            C.Details.NewVideos = C.Details.Videos.Count - old;

            DefaultAlgorithm algo = new DefaultAlgorithm();

            C.Details.Overall = algo.Calculate(C, Difficulty);
            C.Details.Results = R.pageInfo.totalResults;
        }
Esempio n. 4
0
        public void Test1()
        {
            string zipPath = @"..\..\..\Task1.zip";

            Debug.WriteLine("Name \t\t\t\t Min \t Default \t Special \t Iterate");
            using (var archive = ZipFile.OpenRead(zipPath))
            {
                foreach (var entry in archive.Entries)
                {
                    if (!entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    using (var reader = new StreamReader(entry.Open()))
                    {
                        var input = reader.ReadLine()
                                    .Split(' ')
                                    .Where(x => x != null)
                                    .Select(x => int.Parse(x))
                                    .ToArray();
                        if (input == null || input.Length < 2)
                        {
                            throw new InvalidDataException($"Data in {entry.FullName} is invalid");
                        }
                        var inputDto   = new InputData(input[0], input.Skip(1));
                        var min        = Math.Ceiling((decimal)inputDto.Blanks.Sum(x => x.Length) / inputDto.Rod.Length);
                        var algorithm  = new DefaultAlgorithm();
                        var algorithm2 = new SpecialAlgorithm();
                        //var algorithm3 = new IterateAlgorithm(100, 10);
                        var transposition  = algorithm.GetTransposition(inputDto);
                        var transposition2 = algorithm2.GetTransposition(inputDto);
                        //var transposition3 = algorithm3.GetTransposition(inputDto);
                        var countRod  = inputDto.GetCountRod(transposition);
                        var countRod2 = inputDto.GetCountRod(transposition2);
                        //var countRod3 = inputDto.GetCountRod(transposition3);

                        Debug.WriteLine($"{entry.Name} => \t {min} \t {countRod}\t\t{countRod2}\t\t");
                    }
                }
            }
        }