public List <HistoricalProperty> ReadCode(Codes code, ListDescription listDescription) { if ((int)code < 0 || (int)code > 9) { throw new ArgumentException("Code must be in interval 0-9!"); } if (listDescription == null) { throw new ArgumentNullException("Parameters cannot be null"); } List <HistoricalProperty> hps = new List <HistoricalProperty>(); lock (syncLock) { Logger.WriteLog("Reading code", MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name); } foreach (HistoricalDescription hd in listDescription.HistoricalDescriptions) { foreach (HistoricalProperty hp in hd.HistoricalProperties) { if (hp.Code.Equals(code)) { hps.Add(hp); } } } return(hps); }
public void ReceiveFromModul1GoodParameter() { ListDescription ld = new ListDescription(); Modul1Property m1p = new Modul1Property(); m1p.Code = Code.CODE_ANALOG; m1p.Value = 100; Modul1Property m1p2 = new Modul1Property(); m1p2.Code = Code.CODE_DIGITAL; m1p2.Value = 300; Description d1 = new Description(); d1.Dataset = 1; d1.Id = 12345; d1._m1Property.Add(m1p); Description d2 = new Description(); d2.Dataset = 1; d2.Id = 12346; d2._m1Property.Add(m1p2); ld.m_Description.Add(d1); ld.m_Description.Add(d2); Assert.IsTrue(modul2.ReceiveFromModul1(ld)); }
public ListDescription ReadListDescription(int dataset) { if (dataset < 1 || dataset > 5) { throw new ArgumentException("Something wrong with dataset"); } //call logger ListDescription ld = new ListDescription(); List <HistoricalDescription> list = database.HistoricalDescriptions.Where(x => x.ListDescriptionId == dataset).ToList(); ld.HistoricalDescriptions = list; lock (syncLock) { Logger.WriteLog("Reading list description", MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name); } for (int i = 0; i < ld.HistoricalDescriptions.Count; i++) { int id = ld.HistoricalDescriptions[i].Id; List <HistoricalProperty> hpList = database.HistoricalProperties.Where(x => x.HistoricalDescriptionId == id).ToList(); ld.HistoricalDescriptions[i].HistoricalProperties = hpList; } return(ld); }
/// <summary> /// Adds a list to the description. /// </summary> /// <typeparam name="TList">The type of elements in the list.</typeparam> /// <param name="getList">A function to retrieve the list from the container.</param> /// <returns>A list description, enabling you to specify explicit sub-types of <typeparamref name="TList"/> allowed in the list.</returns> public IListDescription <TContainer, TList> AddList <TList>(Func <TContainer, IList <TList> > getList) where TList : class { var listDescription = new ListDescription <TList>(getList); _descriptions.Add(listDescription); return(listDescription); }
public EditListDescription(IEditModel parent, ListDescription description) { Model = parent; Desc = description; UpdateEntries(); InitializeComponent(); BindingContext = this; }
public void DoesDescriptionExist_NonExistingDescription_ReturnsFalse() { List <IDescription> descriptions = new List <IDescription>(); IListDescription listDescription = new ListDescription(mockedLogger, descriptions); Assert.IsFalse(listDescription.DoesDescriptionExist(Dataset.SET1)); }
private void listOfNamesToolStripMenuItem_Click(object sender, EventArgs e) { ListDescription d = new ListDescription(); new DescriptionForms.ListDescriptionForm(d).ShowDialog(); list.Add(d); fill(); }
/// <summary> /// Adds a list with only one type of element to the description. /// </summary> /// <typeparam name="TElement">The type of elements in the list.</typeparam> /// <param name="name">The name of the element type.</param> /// <param name="getList">A function to retrieve the list from the container.</param> /// <returns>The "this" pointer for use in a "Fluent API" style.</returns> public ContainerDescription <TContainer> AddPlainList <TElement>(string name, Func <TContainer, IList <TElement> > getList) where TElement : class, IEquatable <TElement>, new() { var listDescription = new ListDescription <TElement>(getList); listDescription.AddElement <TElement>(name); _descriptions.Add(listDescription); return(this); }
public void DoesDescriptionExist_ExistingDescription_ReturnsTrue() { IDescription description = MockFullDataset1(); List <IDescription> descriptions = new List <IDescription> { description }; IListDescription listDescription = new ListDescription(mockedLogger, descriptions); Assert.IsTrue(listDescription.DoesDescriptionExist(Dataset.SET1)); }
public void IsDatasetFull_NotFullDataset_ReturnsFalse() { IDescription description = MockEmptyDataset1(); List <IDescription> descriptions = new List <IDescription> { description }; IListDescription listDescription = new ListDescription(mockedLogger, descriptions); Assert.IsFalse(listDescription.IsDatasetFull(Dataset.SET1)); }
public void AddOrReplaceDescription_NonExistingDescription_DescriptionAdded() { IDescription description = MockEmptyDataset1(); List <IDescription> descriptions = new List <IDescription>(); IListDescription listDescription = new ListDescription(mockedLogger, descriptions); Assert.IsEmpty(listDescription.Descriptions); listDescription.AddOrReplaceDescription(description); Assert.AreEqual(listDescription.Descriptions.Count, 1); }
public void GetDescriptionByDataset_ExistingDescription_AssertContent() { IDescription description = MockFullDataset1(); List <IDescription> descriptions = new List <IDescription> { description }; IListDescription listDescription = new ListDescription(mockedLogger, descriptions); Dataset dataset = Dataset.SET1; Assert.AreEqual(listDescription.GetDescriptionByDataset(dataset).Dataset, dataset); }
public void GetDescriptionByDataset_NonExistingDescription_ReturnsNull() { IDescription description = MockFullDataset1(); List <IDescription> descriptions = new List <IDescription> { description }; IListDescription listDescription = new ListDescription(mockedLogger, descriptions); Dataset dataset = Dataset.SET2; Assert.IsNull(listDescription.GetDescriptionByDataset(dataset)); }
/// <summary> /// Singleton pattern, omogucuje da uvijek imamo samo jednu instancu Historical-a /// </summary> /// <returns> Return instance of class </returns> public static Historical Instance() { if (instance == null) { instance = new Historical(); LD1 = new ListDescription(); LD2 = new ListDescription(); LD3 = new ListDescription(); LD4 = new ListDescription(); } return(instance); }
/// <summary> /// Funkcija provjerava da li podaci izlaze iz Deadband-a /// </summary> /// <param name="LD"> LD koji se provjerava </param> /// <param name="manual"> parametar govori da li se radi o rucnom upisu </param> /// <returns> </returns> private bool CheckDeadband(ListDescription LD, bool manual) { if (!manual) { //Ukoliko LD struktura ima samo 1 HistoricalDescription, upisi ga, nema provjere Deadband-a if (LD.ListHistoricalDesc.Count == 1) { return(true); } } foreach (HistoricalProperty hp in historicalProperties) { //Za CODE_DIGITAL se ne provjerava Deadbend if (hp.Code == Codes.CODE_DIGITAL) { return(true); } //Provjera DeadBend-a foreach (HistoricalDescription hd in LD.ListHistoricalDesc) { foreach (HistoricalProperty histProperty in hd.HistoricalProperties) { if (hp.Code == histProperty.Code) { //izlazi id deadband-a if (hp.HistoricalValue < (histProperty.HistoricalValue - (histProperty.HistoricalValue / 100) * 2) || hp.HistoricalValue > (histProperty.HistoricalValue + (histProperty.HistoricalValue / 100) * 2)) { //Izlazi iz Deadband-a } else { if (hp.Time == histProperty.Time) { //znaci da se radi o istom HistoricalProperty-u } else { return(false); } } } } } } return(true); }
public List <HistoricalProperty> GetChangesForInterval(Codes code) { if ((int)code < 0 || (int)code > 9) { throw new ArgumentException("Code must be in interval 0-9!"); } int dataset = historical.CheckDataset(code); ListDescription listDescription = historical.ReadOneLDFromDB(dataset); lock (syncLock) { Logger.WriteLog("Getting changes for interval", MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name); } return(ReadCode(code, listDescription)); }
public void AddOrReplaceProperty_ExistingDescription_VerifyAddPropertyCalled() { Mock <IDescription> description = new Mock <IDescription>(); description.SetupGet(x => x.Dataset).Returns(Dataset.SET1); List <IDescription> descriptions = new List <IDescription> { description.Object }; IListDescription listDescription = new ListDescription(mockedLogger, descriptions); IModule1Property newProperty = MockModule1Property(SignalCode.CODE_ANALOG, 120); listDescription.AddOrReplaceProperty(newProperty); description.Verify(x => x.AddOrReplaceProperty(newProperty), Times.Exactly(1)); }
// prima podatke od Modula1 ili direktno od Inputa // skladisti podatke u xml fajl // po vrsti dataset-a(kojih ima 4 vrste-1,2,3,4) ima i razlicite baze(4 xml fajla) // podaci su skladisteni u formi CollectionDescription-a public bool ReceiveFromModul1(ListDescription listdescription) { if (listdescription == null) { throw new ArgumentNullException("listdescription"); } foreach (Description d in listdescription.m_Description) { m_CollectionDescription = new CollectionDescription(); m_CollectionDescription.Id = d.Id; m_CollectionDescription.timeStamp = DateTime.Now; foreach (Modul1Property dp in d._m1Property) { Modul2Property hp = new Modul2Property(); hp.Code = dp.Code; help = dp.Code; hp.Modul2Value = dp.Value; m_CollectionDescription.m_HistoricalCollection.m_Modul2Property[0] = hp; } m_CollectionDescription.Dataset = d.Dataset; if (ValidationCheck(m_CollectionDescription.m_HistoricalCollection.m_Modul2Property[0].Code, m_CollectionDescription.Dataset)) { Logger.Log("\nReceiveFromModul1 u Modulu2 prepakovalo je posatke u ColectionDescription.\n"); Logger.Log("CD : " + m_CollectionDescription + "\n"); Serialize(m_CollectionDescription); } else { Logger.Log("Validacija Dataset-a u Modulu2 nije prosla.\n"); return false; } } return true; }
public void AddOrReplaceDescription_ExistingDescription_DescriptionReplaced() { IDescription description = MockFullDataset1(); List <IDescription> descriptions = new List <IDescription> { description }; IListDescription listDescription = new ListDescription(mockedLogger, descriptions); Assert.AreEqual(listDescription.Descriptions[0].Properties.Count, 2); IDescription descriptionNew = MockEmptyDataset1(); listDescription.AddOrReplaceDescription(descriptionNew); Assert.AreEqual(listDescription.Descriptions[0].Properties.Count, 0); }
public void AddOrReplaceProperty_NonExistingDescription_PropertyAdded() { List <IDescription> descriptions = new List <IDescription>(); IListDescription listDescription = new ListDescription(mockedLogger, descriptions); Assert.AreEqual(listDescription.Descriptions.Count, 0); IModule1Property newProperty = MockModule1Property(SignalCode.CODE_ANALOG, 120); listDescription.AddOrReplaceProperty(newProperty); Assert.AreEqual(listDescription.Descriptions.Count, 1); Assert.AreEqual(listDescription.Descriptions[0].Dataset, Dataset.SET1); Assert.AreEqual(listDescription.Descriptions[0].Properties.Count, 1); Assert.AreEqual(listDescription.Descriptions[0].Properties[0].Code, SignalCode.CODE_ANALOG); Assert.AreEqual(listDescription.Descriptions[0].Properties[0].Module1Value, 120); }
public void AddHistoricalDescription(HistoricalDescription hd, int dataset) { if (hd == null) { throw new ArgumentNullException("Arguments cannot be null"); } if (dataset < 1 || dataset > 5) { throw new ArgumentException("Something wrong with dataset"); } //call logger lock (syncLock) { Logger.WriteLog("Adding historical description", MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name); } ListDescription list1 = database.ListDescriptions.Where(x => x.Id == dataset).FirstOrDefault(); if (list1 == null) { throw new ArgumentNullException("Object reference not set to instance of an object(list null for db)"); } list1.HistoricalDescriptions.Add(hd); database.SaveChanges(); }
/// <summary> /// Funkcija za deserijalizaciju ListDescription struktura. /// </summary> public void LoadLD() { XmlSerializer deserializer = new XmlSerializer(typeof(ListDescription)); try { TextReader reader1 = new StreamReader(@"..\..\..\LD1.xml"); LD1 = (ListDescription)deserializer.Deserialize(reader1); reader1.Close(); } catch { } try { TextReader reader2 = new StreamReader(@"..\..\..\LD2.xml"); LD2 = (ListDescription)deserializer.Deserialize(reader2); reader2.Close(); } catch { } try { TextReader reader3 = new StreamReader(@"..\..\..\LD3.xml"); LD3 = (ListDescription)deserializer.Deserialize(reader3); reader3.Close(); } catch { } try { TextReader reader4 = new StreamReader(@"..\..\..\LD4.xml"); LD4 = (ListDescription)deserializer.Deserialize(reader4); reader4.Close(); } catch { } }
internal void ListAsRental() { //Populate excel file ExcelLib.PopulateInCollection(Config.Keys_Resource.ExcelPath, "ListRental"); Thread.Sleep(1000); //calling the common methods Common_methods(); Thread.Sleep(500); //Select properties page PropertiesPage.Click(); //Clicking on save button ListaRental.Click(); Driver.wait(2000); //Enter Title Title.SendKeys(ExcelLib.ReadData(2, "Title")); Driver.wait(2000); //Enter moving cost MovingCost.SendKeys(ExcelLib.ReadData(2, "MovingCost")); Driver.wait(2000); //Enter List Description ListDescription.SendKeys(ExcelLib.ReadData(2, "Description")); Driver.wait(2000); //Enter List target rent ListTargetRent.SendKeys(ExcelLib.ReadData(2, "TargetRent")); Driver.wait(2000); //Enter Available date AvailableDate.Clear(); Driver.wait(500); AvailableDate.SendKeys("31/08/2018"); Driver.wait(2000); //Enter Occupant Count OccupantCount.SendKeys(ExcelLib.ReadData(2, "Occupants")); Driver.wait(2000); //Upload a file thru AutoIT Driver.wait(1000); AutoItX3 autoIT = new AutoItX3(); Uploadingfile.Click(); autoIT.WinActivate("Open"); Thread.Sleep(1000); autoIT.Send(@"C:\Users\VictorFelix\source\repos\automationOnboardingSample-master\Keys_Onboarding\TestReports\Screenshots\home.jpg"); Thread.Sleep(1000); autoIT.Send("{Enter}"); Thread.Sleep(1000); //Clicking on Save ListSave.Click(); Driver.wait(2000); //Clicking on OK on Alert //Driver.driver.SwitchTo().Alert().Accept(); //Driver.wait(2000); //Click on the Owners tab Ownertab.Click(); Thread.Sleep(1000); //Click on the Rental Listings button RentalListings.Click(); Thread.Sleep(1000); //Search for added list property SearchBox.SendKeys(ExcelLib.ReadData(2, "Title")); Driver.wait(2000); //Clicking on Search icon SearchBtn.Click(); Driver.wait(2000); }