Пример #1
0
    public static void Add()
    {
        var data1 = new BooleanData(3u, 1u, 2u);
        var data2 = new BooleanData(30u, 10u, 20u);
        var data3 = data1.Add(data2);

        Assert.That(data3.TotalOccurences, Is.EqualTo(33u), nameof(data3.TotalOccurences));
        Assert.That(data3.TrueOccurences, Is.EqualTo(11u), nameof(data3.TrueOccurences));
        Assert.That(data3.FalseOccurences, Is.EqualTo(22u), nameof(data3.FalseOccurences));
    }
Пример #2
0
    public static void UpdateWithFalse()
    {
        var data = new BooleanData(3u, 1u, 2u);

        data = data.Update(false);

        Assert.That(data.TotalOccurences, Is.EqualTo(4u), nameof(data.TotalOccurences));
        Assert.That(data.TrueOccurences, Is.EqualTo(1u), nameof(data.TrueOccurences));
        Assert.That(data.FalseOccurences, Is.EqualTo(3u), nameof(data.FalseOccurences));
    }
Пример #3
0
 public Object serializeAnswerData(BooleanData data)
 {
     if (((Boolean)data.Value))
     {
         return("1");
     }
     else
     {
         return("0");
     }
 }
Пример #4
0
    public static void Create()
    {
        var totalOccurences = 3u;
        var trueOccurences  = 1u;
        var falseOccurences = 2u;

        var data = new BooleanData(totalOccurences, trueOccurences, falseOccurences);

        Assert.That(data.TotalOccurences, Is.EqualTo(totalOccurences), nameof(data.TotalOccurences));
        Assert.That(data.TrueOccurences, Is.EqualTo(trueOccurences), nameof(data.TrueOccurences));
        Assert.That(data.FalseOccurences, Is.EqualTo(falseOccurences), nameof(data.FalseOccurences));
    }
Пример #5
0
        public static string RandomiseCase(this string str)
        {
            var random  = new Random();
            var builder = new StringBuilder();

            foreach (var character in str)
            {
                var isUpperCase = BooleanData.GetBoolean();
                builder.Append(isUpperCase ? Char.ToUpper(character) : Char.ToLower(character));
            }

            return(builder.ToString());
        }
Пример #6
0
        static Settings()
        {
            var        settingsFile = new IniFile("Settings.ini");
            IniSection settingsSection = settingsFile["Settings"], proxySection = settingsFile["Proxy"];

            DownloadPathData = new StringData(settingsSection, "DownloadPath",
                                              Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Downloads"));
            VideoFileNameData = new StringData(settingsSection, "VideoFileName", "%T%E");
            ProxyHostData     = new StringData(proxySection, "Host", "127.0.0.1");
            MaxTasksData      = new Int32Data(settingsSection, "MaxTasks", 50);
            ProxyPortData     = new Int32Data(proxySection, "Port", 8087);
            UseProxyData      = new BooleanData(proxySection, "UseProxy", false);
        }
        public void SetDataValueOnSaveTestExpectDataUpdated()
        {
            var data = new BooleanData()
            {
                SomeValue = false
            };
            var switchCell = new SwitchCellViewModel <BooleanData>(data, (s) => s.SomeValue);

            switchCell.Toggle();
            var result = switchCell.TrySave();

            Assert.AreEqual(true, result.Success);
            Assert.AreEqual(true, data.SomeValue);
        }
 protected override void VerifySyncState(Dictionary <string, DerivedData <ICustomSerializableBuilder> > obj)
 {
     base.VerifySyncState(obj);
     if (base.Version >= 1)
     {
         DateTimeData  dateTimeData  = obj["{9150227d-9140-45d0-b4c2-e987f59cfc46}SyncCalendar.OldestReceivedTime"].Data as DateTimeData;
         ByteArrayData byteArrayData = obj["{9150227d-9140-45d0-b4c2-e987f59cfc46}SyncCalendar.LastInstanceKey"].Data as ByteArrayData;
         BooleanData   booleanData   = obj["{9150227d-9140-45d0-b4c2-e987f59cfc46}SyncCalendar.MoreItemsOnServer"].Data as BooleanData;
         if (dateTimeData == null || byteArrayData == null || booleanData == null)
         {
             throw new CorruptSyncStateException("Empty mandatory key", null);
         }
     }
 }
Пример #9
0
        public static void Initialize()
        {
            Items = new List <TodoItem>();

            for (int i = 0; i < NumberData.GetNumber(10, 25); i++)
            {
                Items.Add(new TodoItem
                {
                    Id             = i,
                    Text           = TextData.GetSentence(),
                    IsHighPriority = BooleanData.GetBoolean(),
                    Status         = EnumData.GetElement <TodoStatus>()
                });
            }
        }
Пример #10
0
        private static void CreateFakeData(AlbumManager albumManager)
        {
            if (albumManager.Query().Any() == false)
            {
                for (int i = 0; i < 5; i++)
                {
                    albumManager.Create(new Album
                    {
                        Name    = NameData.GetCompanyName(),
                        Price   = (decimal)NumberData.GetDouble() * NumberData.GetNumber(100, 4000),
                        IsSales = BooleanData.GetBoolean(),
                        Year    = NumberData.GetNumber(1980, DateTime.Now.Year)
                    });
                }

                Console.WriteLine("Sample data created. Please enter for continue..");
                Console.WriteLine();
                Console.ReadKey();
            }
        }
Пример #11
0
			// Token: 0x0600092E RID: 2350 RVA: 0x000363EC File Offset: 0x000345EC
			public void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool)
			{
				DerivedData<ISyncItemId> derivedData = new DerivedData<ISyncItemId>();
				derivedData.DeserializeData(reader, componentDataPool);
				this.ParentId = derivedData.Data;
				GenericListData<DerivedData<ISyncItemId>, ISyncItemId> genericListData = new GenericListData<DerivedData<ISyncItemId>, ISyncItemId>();
				genericListData.DeserializeData(reader, componentDataPool);
				this.Children = genericListData.Data;
				BooleanData booleanDataInstance = componentDataPool.GetBooleanDataInstance();
				booleanDataInstance.DeserializeData(reader, componentDataPool);
				this.hidden = booleanDataInstance.Data;
				booleanDataInstance.DeserializeData(reader, componentDataPool);
				this.HiddenDueToParent = booleanDataInstance.Data;
				Int32Data int32DataInstance = componentDataPool.GetInt32DataInstance();
				int32DataInstance.DeserializeData(reader, componentDataPool);
				this.Permissions = (SyncPermissions)int32DataInstance.Data;
				StringData stringDataInstance = componentDataPool.GetStringDataInstance();
				stringDataInstance.DeserializeData(reader, componentDataPool);
				this.Owner = stringDataInstance.Data;
			}
Пример #12
0
    public static void VerifyEquality()
    {
        var data1 = new BooleanData(3, 1, 2);
        var data2 = new BooleanData(3, 2, 1);
        var data3 = new BooleanData(3, 1, 2);

        Assert.That(data1, Is.Not.EqualTo(data2));
        Assert.That(data1, Is.EqualTo(data3));
        Assert.That(data2, Is.Not.EqualTo(data3));

#pragma warning disable CS1718 // Comparison made to same variable
        Assert.That(data1 == data1, Is.True);
#pragma warning restore CS1718 // Comparison made to same variable
        Assert.That(data1 == data2, Is.False);
        Assert.That(data1 == data3, Is.True);
        Assert.That(data2 == data3, Is.False);

        Assert.That(data1 != data2, Is.True);
        Assert.That(data1 != data3, Is.False);
        Assert.That(data2 != data3, Is.True);
    }
Пример #13
0
    public static void VerifyHashCodes()
    {
        var data1 = new BooleanData(3, 1, 2);
        var data2 = new BooleanData(3, 2, 1);
        var data3 = new BooleanData(3, 1, 2);

        Assert.That(data1.GetHashCode(), Is.Not.EqualTo(data2.GetHashCode()));
        Assert.That(data1.GetHashCode(), Is.EqualTo(data3.GetHashCode()));

        data1 = new BooleanData(43, 20, 23);
        data2 = new BooleanData(43, 23, 20);
        data3 = new BooleanData(43, 20, 23);

        Assert.That(data1.GetHashCode(), Is.Not.EqualTo(data2.GetHashCode()));
        Assert.That(data1.GetHashCode(), Is.EqualTo(data3.GetHashCode()));

        data1 = new BooleanData(112, 111, 1);
        data2 = new BooleanData(111, 110, 1);
        data3 = new BooleanData(112, 111, 1);

        Assert.That(data1.GetHashCode(), Is.Not.EqualTo(data2.GetHashCode()));
        Assert.That(data1.GetHashCode(), Is.EqualTo(data3.GetHashCode()));
    }
 public DotnetStyleQualificationForEventStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
Пример #15
0
 public CSharpStyleInlinedVariableDeclarationStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
 public CSharpStyleVarForBuiltInTypesStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
Пример #17
0
 public DotnetStylePreferInferredTupleNamesStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
Пример #18
0
 public CSharpStyleVarWhenTypeIsApparentStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
 public CSharpNewLineBeforeCatchStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
Пример #20
0
        public void Generate()
        {
            var random = new Random();

            client.PutIndex(new RavenDocumentsByEntityName());
            client.PutIndex(new OrdersByCompany());
            client.PutIndex(new OrdersTotals());
            client.PutIndex(new ProductSales());
            client.PutIndex(new OrdersByEmployeeAndCompany());
            client.PutIndex(new OrdersByEmployeeAndCompanyReduce());

            var nextOrderId    = 1;
            var nextCompanyId  = 1;
            var nextProductId  = 1;
            var nextEmployeeId = 1;

            for (var it = 0; it < numberOfIterations; it++)
            {
                var entities = new List <object>();

                for (var i = 0; i < NumberOfOrdersPerIteration; i++)
                {
                    entities.Add(new Order
                    {
                        Id      = "orders/" + nextOrderId++,
                        Company = "companies/" + random.Next(1, ExpectedNumberOfCompanies - 1),
                        Lines   = CollectionData.GetElement(10, new List <OrderLine>
                        {
                            new OrderLine
                            {
                                Product      = "products/" + random.Next(1, ExpectedNumberOfProducts - 1),
                                Quantity     = random.Next(1, 100),
                                PricePerUnit = random.Next(1000)
                            }
                        }).ToList(),
                        Employee  = "employees/" + random.Next(1, ExpectedNumberOfEmployees - 1),
                        OrderedAt = DateTimeData.GetDatetime(),
                        RequireAt = DateTime.UtcNow.AddDays(7),
                        ShipTo    = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfCompaniesPerIteration; i++)
                {
                    entities.Add(new Company
                    {
                        Id      = "companies/" + nextCompanyId++,
                        Name    = NameData.GetCompanyName(),
                        Fax     = PhoneNumberData.GetInternationalPhoneNumber(),
                        Address = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfEmployeesPerIteration; i++)
                {
                    entities.Add(new Employee
                    {
                        Id        = "employees/" + nextEmployeeId++,
                        Birthday  = DateTimeData.GetDatetime(),
                        FirstName = NameData.GetFirstName(),
                        LastName  = NameData.GetSurname(),
                        HomePhone = PhoneNumberData.GetPhoneNumber(),
                        HiredAt   = DateTimeData.GetDatetime(),
                        Address   = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfProductsPerIteration; i++)
                {
                    entities.Add(new Product
                    {
                        Id           = "products/" + nextProductId++,
                        Category     = TextData.GetAlphabetical(5),
                        Name         = NameData.GetSurname(),
                        Discontinued = BooleanData.GetBoolean(),
                        PricePerUnit = NumberData.GetNumber()
                    });
                }

                client.PutEntities(entities);
            }
        }
Пример #21
0
 public CSharpStylePatternLocalOverAnonymousFunctionStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
 public CSharpSpaceAfterCastStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
Пример #23
0
        public override void HandleSyncStateVersioning(SyncState syncState)
        {
            if (syncState == null)
            {
                throw new ArgumentNullException("syncState");
            }
            if (syncState.BackendVersion == null)
            {
                return;
            }
            bool flag = true;

            if (syncState.BackendVersion < 3 || syncState.BackendVersion > this.Version)
            {
                flag = false;
            }
            else if (syncState.BackendVersion.Value != this.Version)
            {
                int value = syncState.BackendVersion.Value;
                switch (value)
                {
                case 3:
                    syncState["ClientCanSendUpEmptyRequests"] = new BooleanData(false);
                    syncState["LastSyncRequestRandomString"]  = new StringData(string.Empty);
                    break;

                case 4:
                    break;

                case 5:
                    goto IL_114;

                default:
                    switch (value)
                    {
                    case 20:
                        goto IL_124;

                    case 21:
                    case 22:
                        goto IL_150;

                    case 23:
                        goto IL_166;

                    case 24:
                        goto IL_172;

                    case 25:
                        goto IL_17D;

                    default:
                        flag = false;
                        goto IL_18C;
                    }
                    break;
                }
                syncState["ClientCanSendUpEmptyRequests"] = new BooleanData(false);
                syncState.Remove("IsXmlValidBool");
IL_114:
                syncState["LastClientIdsSent"] = new GenericListData <StringData, string>();
IL_124:
                syncState["LastCachableWbxmlDocument"]    = new ByteArrayData();
                syncState["ClientCanSendUpEmptyRequests"] = new BooleanData(false);
                syncState.Remove("XmlDocumentString");
IL_150:
                syncState["LastAdUpdateTime"] = syncState.GetData <DateTimeData>("LastAdUpdateTime");
IL_166:
                syncState["ClientCategoryList"] = null;
IL_172:
                syncState.Remove("LastAdUpdateTime");
IL_17D:
                syncState.Remove("MailboxLog");
            }
IL_18C:
            if (!flag)
            {
                syncState.HandleCorruptSyncState();
            }
        }
 public DotnetStylePredefinedTypeForMemberAccessStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
        private static AllTypesModel GenerateSimpleModel(Random random, int min, int max)
        {
            var itemToAdd = new AllTypesModel
            {
                Long         = NumberData.GetNumber(min, max),
                LongNullable = RandomiseNullable(NumberData.GetNumber(min, max)),
#if USE_UTYPES
                ULong         = (ulong)NumberData.GetNumber(0, max),
                ULongNullable = RandomiseNullable((ulong)NumberData.GetNumber(0, max)),
#else
                ULong         = (long)NumberData.GetNumber(0, max),
                ULongNullable = (long?)RandomiseNullable(NumberData.GetNumber(0, max)),
#endif
                Integer         = random.Next(min, max),
                IntegerNullable = RandomiseNullable(FakeData.NumberData.GetNumber(min, max)),

#if USE_UTYPES
                UInt         = (uint)NumberData.GetNumber(0, max),
                UIntNullable = (uint?)RandomiseNullable(NumberData.GetNumber(0, max)),
#else
                UInt         = (int)NumberData.GetNumber(0, max),
                UIntNullable = (int?)RandomiseNullable(NumberData.GetNumber(0, max)),
#endif
                DoubleProperty = NumberData.GetDouble(),
                DoubleNullable = RandomiseNullable(NumberData.GetDouble()),

                Float         = (float)NumberData.GetDouble(),
                FloatNullable = RandomiseNullable((float)NumberData.GetDouble()),

                DecimalProperty = (decimal)NumberData.GetDouble(),
                DecimalNullable = (decimal?)RandomiseNullable(NumberData.GetDouble()),

                Short         = (short)NumberData.GetNumber(min, max),
                ShortNullable = (short?)(NumberData.GetNumber(min, max)),
#if USE_UTYPES
                UShort         = (ushort)NumberData.GetNumber(0, max),
                UShortNullable = (ushort?)RandomiseNullable(NumberData.GetNumber(0, max)),
#else
                UShort         = (short)NumberData.GetNumber(0, max),
                UShortNullable = (short?)RandomiseNullable(NumberData.GetNumber(0, max)),
#endif
                ByteProperty = RandomByte(),
                ByteNullable = RandomiseNullable(RandomByte()),
#if USE_STYPES
                SByteProperty = RandomSByte(),
                SByteNullable = RandomiseNullable(RandomSByte()),
#else
                SByteProperty = RandomByte(),
                SByteNullable = RandomiseNullable(RandomByte()),
#endif

#if USE_CHARTYPE
                CharProperty = FakeData.TextData.GetAlphabetical(1)[0],
                CharNullable = RandomiseNullable(FakeData.TextData.GetAlphabetical(1)[0]),
#else
                CharProperty = FakeData.TextData.GetAlphabetical(1)[0].ToString(),
                CharNullable = RandomiseNullable(TextData.GetAlphaNumeric(1), 0.3),
#endif

                BooleanProperty = BooleanData.GetBoolean(),
                BooleanNullable = RandomiseNullable(BooleanData.GetBoolean()),

                StringProperty = RandomiseNullable(TextData.GetAlphaNumeric(NumberData.GetNumber(0, 20)), 0.3),

                DateTimeProperty = RandomDate(max),
                DateTimeNullable = RandomiseNullable(RandomDate(max)),
#if USE_DTOFFSET
                DateTimeOffsetProperty = RandomDateTimeOffset(max),
                DateTimeOffsetNullable = RandomiseNullable(RandomDateTimeOffset(max))
#else
                DateTimeOffsetProperty = RandomDate(max),
                DateTimeOffsetNullable = RandomiseNullable(RandomDate(max)),
#endif
            };

            return(itemToAdd);
        }
 public DotnetStyleExplicitTupleNamesStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
Пример #27
0
 public CSharpStyleVarElsewhereStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
Пример #28
0
 public CSharpStylePatternMatchingOverAsWithNullCheckStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
 public CSharpPreserveSingleLineBlocksStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }
 public DotnetStylePredefinedTypeForLocalsParametersMembersStyle(BooleanData data, Severity severity = Severity.Error)
     : base(data, severity)
 {
 }