Example #1
0
 public void NormalizeAfterFinalization()
 {
     Relevance rel = new Relevance(8);
     rel.Finalize(16);
     rel.NormalizeAfterFinalization(0.5F);
     Assert.AreEqual(25, rel.Value, 0.1, "Wrong value");
 }
Example #2
0
        public void Constructor_WithValue()
        {
            Relevance rel = new Relevance(5);

            Assert.Equal(5, rel.Value);
            Assert.False(rel.IsFinalized, "Value should not be finalized");
        }
Example #3
0
        public void Constructor()
        {
            Relevance rel = new Relevance();

            Assert.AreEqual(0, rel.Value, "Wrong value");
            Assert.IsFalse(rel.IsFinalized, "Value should not be finalized");
        }
Example #4
0
        private void RelevanceData()
        {
            var    libItemsCount = lvLibItems.Items.Count;
            double step          = libItemsCount / 100;

            var time = DateTime.Now;

            log.Write($"{ time.ToString() }");
            log.Write($"> Find relevance where libItems count = {lvLibItems.Items.Count} ");

            // var relevance = new Relevance(lvLibItems.Items.Cast<ListViewItem>().Select(item => (LibItem)item.Tag).ToList());
            var relevance      = new Relevance(libItems);
            var relevanceItems = relevance.GetRelevance();

            deletedLibItems.AddRange(libItems.Except(relevanceItems).ToList());
            libItems = relevanceItems;
            LoadLibItems();

            log.Write($"{ (DateTime.Now - time).TotalSeconds.ToString() } sec.");
            log.Write("____________________");

            pbLoadUniqueData.Value = 100;
            MessageBox.Show("Готово!");
            pbLoadUniqueData.Value = 0;
        }
Example #5
0
        public void SetValue_Value_Invalid()
        {
            Relevance sut = new Relevance();
            var       ex  = Assert.Throws <ArgumentOutOfRangeException>(() => sut.SetValue(-1));

            Assert.Equal("Value must be greater than or equal to zero.\r\nParameter name: value", ex.Message);
        }
Example #6
0
 public void Finalize_AlreadyFinalized()
 {
     Relevance rel = new Relevance();
     rel.SetValue(8);
     rel.Finalize(0.5F);
     rel.Finalize(1);
 }
Example #7
0
        public void NormalizeAfterFinalization_InvalidFactor()
        {
            Relevance rel = new Relevance(8);

            rel.Finalize(16);
            rel.NormalizeAfterFinalization(-0.5F);
        }
Example #8
0
        public void NormalizeAfterFinalization_InvalidFactor()
        {
            Relevance rel = new Relevance(8);

            rel.Finalize(16);
            Assert.Throws <ArgumentOutOfRangeException>(() => { rel.NormalizeAfterFinalization(-0.5F); });
        }
Example #9
0
        public void Finalize_InvalidFactor()
        {
            Relevance rel = new Relevance();

            rel.SetValue(8);
            Assert.Throws <ArgumentOutOfRangeException>(() => { rel.Finalize(-1); });
        }
Example #10
0
        public void NormalizeAfterFinalization_BeforeFinalize()
        {
            Relevance sut = new Relevance(8);
            var       ex  = Assert.Throws <InvalidOperationException>(() => sut.NormalizeAfterFinalization(0.5F));

            Assert.Equal("Normalization can be performed only after finalization.", ex.Message);
        }
Example #11
0
        public void Finalize_InvalidFactor()
        {
            Relevance rel = new Relevance();

            rel.SetValue(8);
            rel.Finalize(-1);
        }
Example #12
0
        public void Finalize_Total_Invalid()
        {
            Relevance sut = new Relevance(2);
            var       ex  = Assert.Throws <ArgumentOutOfRangeException>(() => sut.Finalize(-1));

            Assert.Equal("Total must be greater than or equal to zero.\r\nParameter name: total", ex.Message);
        }
Example #13
0
        public void Constructor_WithValue()
        {
            var rel = new Relevance(5);

            Assert.AreEqual(5, rel.Value, "Wrong value");
            Assert.IsFalse(rel.IsFinalized, "Value should not be finalized");
        }
Example #14
0
        public void NormalizeAfterFinalization()
        {
            Relevance rel = new Relevance(8);

            rel.Finalize(16);
            rel.NormalizeAfterFinalization(0.5F);
            Assert.AreEqual(25, rel.Value, 0.1, "Wrong value");
        }
Example #15
0
        public void SetValue_AfterFinalize()
        {
            Relevance rel = new Relevance();

            rel.SetValue(5);
            rel.Finalize(12);
            rel.SetValue(8);
        }
Example #16
0
        public void Finalize_AlreadyFinalized()
        {
            Relevance rel = new Relevance();

            rel.SetValue(8);
            rel.Finalize(0.5F);
            rel.Finalize(1);
        }
Example #17
0
        public void NormalizeAfterFinalization()
        {
            Relevance rel = new Relevance(8);

            rel.Finalize(16);
            rel.NormalizeAfterFinalization(0.5F);
            Assert.Equal(25, rel.Value, 1);
        }
Example #18
0
        public void SetValue_AfterFinalize()
        {
            Relevance rel = new Relevance();

            rel.SetValue(5);
            rel.Finalize(12);
            Assert.Throws <InvalidOperationException>(() => { rel.SetValue(8); });
        }
Example #19
0
        public void Finalize_AlreadyFinalized()
        {
            Relevance rel = new Relevance();

            rel.SetValue(8);
            rel.Finalize(0.5F);
            Assert.Throws <InvalidOperationException>(() => { rel.Finalize(1); });
        }
Example #20
0
 public void Finalize_()
 {
     Relevance rel = new Relevance();
     rel.SetValue(12);
     Assert.AreEqual(12, rel.Value, "Wrong value");
     rel.Finalize(24);
     Assert.AreEqual(50, rel.Value, "Wrong finalized value");
     Assert.IsTrue(rel.IsFinalized, "Value should be finalized");
 }
Example #21
0
        // Underscore to avoid interference with Destructor
        public void Finalize_()
        {
            Relevance rel = new Relevance();

            rel.SetValue(12);
            Assert.AreEqual(12, rel.Value, "Wrong value");
            rel.Finalize(24);
            Assert.AreEqual(50, rel.Value, "Wrong finalized value");
            Assert.IsTrue(rel.IsFinalized, "Value should be finalized");
        }
Example #22
0
        // Underscore to avoid interference with Destructor
        public void Finalize_()
        {
            Relevance rel = new Relevance();

            rel.SetValue(12);
            Assert.Equal(12, rel.Value);
            rel.Finalize(24);
            Assert.Equal(50, rel.Value);
            Assert.True(rel.IsFinalized, "Value should be finalized");
        }
Example #23
0
        public void Finalize_Already_Performed()
        {
            Relevance sut = new Relevance();

            sut.SetValue(0);
            sut.Finalize(0.5F);
            var ex = Assert.Throws <InvalidOperationException>(() => sut.Finalize(1));

            Assert.Equal("Finalization already performed.", ex.Message);
        }
Example #24
0
        /// <summary>
        /// 闸机绑定楼栋信息
        /// </summary>
        /// <param name="deviceNumber"></param>
        /// <param name="buildingId"></param>
        public void BindBuildings(string deviceNumber, string buildingId)
        {
            var relevance = new Relevance();

            relevance.Name      = "Gate_Building";
            relevance.FirstKey  = deviceNumber;
            relevance.SecondKey = buildingId;

            AddAndSave(relevance);
        }
Example #25
0
        public void SetValue()
        {
            Relevance rel = new Relevance();

            rel.SetValue(8);
            Assert.AreEqual(8, rel.Value, "Wrong value");
            Assert.IsFalse(rel.IsFinalized, "Value should not be finalized");
            rel.SetValue(14);
            Assert.AreEqual(14, rel.Value, "Wrong value");
            Assert.IsFalse(rel.IsFinalized, "Value should not be finalized");
        }
Example #26
0
        /// <summary>
        /// 根据大屏设备号获取绑定的楼栋列表
        /// </summary>
        /// <param name="relevance"></param>
        /// <returns></returns>
        public List <Building> GetBindGate(Relevance relevance)
        {
            if (relevance == null)
            {
                return(Read <Building>().ToList());
            }

            var relevances = Read <Relevance>(p => p.FirstKey == relevance.FirstKey && p.Name == "Device_Building").FirstOrDefault()?.SecondKey.Split(',').ToList();

            var list = Read <Building>(p => relevances.Contains(p.Id)).ToList();

            return(list);
        }
Example #27
0
 /// <summary>
 /// 绑定楼栋的宿管
 /// </summary>
 public void BindUsers(string id, string[] users)
 {
     foreach (var user in users)
     {
         var rel = new Relevance
         {
             Name      = Relation.BuildingUser,
             FirstKey  = id,
             SecondKey = user
         };
         AddAndSave(rel);
     }
     SaveChanges();
 }
Example #28
0
 public void BindBuilding(string id, string[] buildings)
 {
     foreach (var item in buildings)
     {
         var rel = new Relevance
         {
             Name      = Relation.GateBuilding,
             FirstKey  = id,
             SecondKey = item
         };
         AddAndSave(rel);
     }
     SaveChanges();
 }
Example #29
0
 public UserStory(
     string title,
     Priority priority,
     string text,
     string acceptanceCriteria,
     BusinessValue businessValue,
     Relevance relevance = Relevance.CouldHave) : this()
 {
     Title              = title;
     Priority           = priority;
     Text               = text;
     AcceptanceCriteria = acceptanceCriteria;
     BusinessValue      = businessValue;
     Importance         = relevance;
 }
Example #30
0
        public void BindBuilding(string id, string[] buildings)
        {
            var ReleList = new List <Relevance>();

            foreach (var item in buildings)
            {
                var rel = new Relevance
                {
                    Name      = Relation.DeviceBuilding,
                    FirstKey  = id,
                    SecondKey = item
                };
                ReleList.Add(rel);
            }
            AddRange(ReleList);
            SaveChanges();
        }
Example #31
0
    private void OnPeerDisconnect(P2PNetworkMessage net_msg)
    {
        P2PConnection connection = net_msg.m_Connection;
        P2PPeer       p2PPeer    = (connection != null) ? connection.m_Peer : null;

        if (p2PPeer != null)
        {
            Dictionary <GameObject, Relevance> .Enumerator enumerator = this.m_Components.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <GameObject, Relevance> keyValuePair = enumerator.Current;
                Relevance value = keyValuePair.Value;
                if (value)
                {
                    value.OnPeerDisconnected(p2PPeer);
                }
            }
            enumerator.Dispose();
        }
    }
Example #32
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Entities.BusinessEntity.Select().ForEach(x => BusinessEntity.Items.Add(Entities.BusinessEntity.ToTextBlock(x)));
     Entities.Activity.Select().ForEach(x => Activity.Items.Add(Entities.Activity.ToTextBlock(x)));
     Entities.ActivityDirection.Select().ForEach(x => ActivityDirection.Items.Add(Entities.ActivityDirection.ToTextBlock(x)));
     Entities.Region.Select().ForEach(x => Region.Items.Add(Entities.Region.ToTextBlock(x)));
     if (Dealer == null)
     {
         Dealer = new Dealer();
         BusinessEntity.SelectItem();
         Activity.SelectItem();
         ActivityDirection.SelectItem();
         Region.SelectItem();
         Title = "Добавление дилера";
     }
     else
     {
         BusinessEntity.SelectItem(BusinessEntity.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == Dealer.BusinessEntityId));
         _Name.Text = Dealer.Name;
         Activity.SelectItem(Activity.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == Dealer.ActivityId));
         ActivityDirection.SelectItem(ActivityDirection.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == Dealer.ActivityDirectionId));
         Rating.SelectItem(selectedIndex: 5 - (int)Dealer.Rating);
         Relevance.SelectItem(selectedIndex: Dealer.IsRelevant ? 0 : 1);
         Region.SelectItem(Region.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == Dealer.RegionId));
         City.Text   = Dealer.City;
         Street.Text = Dealer.Street;
         House.Text  = Dealer.House;
         Block.Text  = Dealer.Block;
         Room.Text   = Dealer.Room;
         UpdateContacts();
         Contacts.SelectItem();
         Note.Text       = Dealer.Note;
         Conditions.Text = Dealer.Conditions;
         UpdateEvents();
         Events.SelectItem(selectedIndex: 1);
         Title = "Правка дилера";
     }
 }
Example #33
0
        public void Finalize_InvalidTotal()
        {
            Relevance rel = new Relevance(2);

            rel.Finalize(-1);
        }
Example #34
0
 public void SetValue()
 {
     Relevance rel = new Relevance();
     rel.SetValue(8);
     Assert.AreEqual(8, rel.Value, "Wrong value");
     Assert.IsFalse(rel.IsFinalized, "Value should not be finalized");
     rel.SetValue(14);
     Assert.AreEqual(14, rel.Value, "Wrong value");
     Assert.IsFalse(rel.IsFinalized, "Value should not be finalized");
 }
Example #35
0
 public void SetValue_AfterFinalize()
 {
     Relevance rel = new Relevance();
     rel.SetValue(5);
     rel.Finalize(12);
     rel.SetValue(8);
 }
Example #36
0
 public void SetValue_InvalidValue()
 {
     Relevance rel = new Relevance();
     rel.SetValue(-1);
 }
Example #37
0
 public void Constructor_InvalidValue()
 {
     Relevance rel = new Relevance(-1);
 }
Example #38
0
 public void Constructor_WithValue()
 {
     Relevance rel = new Relevance(5);
     Assert.AreEqual(5, rel.Value, "Wrong value");
     Assert.IsFalse(rel.IsFinalized, "Value should not be finalized");
 }
Example #39
0
 public void Finalize_InvalidFactor()
 {
     Relevance rel = new Relevance();
     rel.SetValue(8);
     rel.Finalize(-1);
 }
Example #40
0
 public void Finalize_InvalidTotal()
 {
     Relevance rel = new Relevance(2);
     rel.Finalize(-1);
 }
Example #41
0
 public void NormalizeAfterFinalization_BeforeFinalize()
 {
     Relevance rel = new Relevance(8);
     rel.NormalizeAfterFinalization(0.5F);
 }
Example #42
0
 public void NormalizeAfterFinalization_InvalidFactor()
 {
     Relevance rel = new Relevance(8);
     rel.Finalize(16);
     rel.NormalizeAfterFinalization(-0.5F);
 }