public void Reset(ListenPickUpMsg msg) { //if (_State != msg.State) { if (msg.State != FunctionState.Error) { switch (msg.State) { case FunctionState.Executing: if (string.IsNullOrEmpty(msg.OtherDst)) { StateDescription = Resources.ForwardDescription + " " + msg.Dst; } else { StateDescription = Resources.ForwardDescription + " " + msg.OtherDst + " " + Resources.From + " " + msg.Dst; } break; case FunctionState.Idle: case FunctionState.Ready: if (!StateDescription.Contains(Resources.RemoteForwardDescription)) { StateDescription = ""; } break; } } State = msg.State; } }
public void RepositoryStateDescriptionAddMultipleTest() { DataRepository dr = new DataRepository(); List <StateDescription> stateDescriptions = new List <StateDescription>(); for (int i = 0; i < 100; i++) { StateDescription stateDescription = new StateDescription(new Catalog("Pride and Prejudice", "This is description", "Jane Austen"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null).AddDays(i), "here"); stateDescriptions.Add(stateDescription); dr.AddStateDescription(stateDescription); } for (int i = 0; i < 100; i++) { Assert.AreEqual(stateDescriptions[i], dr.GetStateDescriptionByCode(stateDescriptions[i].Code)); } int count = 0; IEnumerator <StateDescription> enumerator = dr.GetAllStateDescriptions().GetEnumerator(); while (enumerator.MoveNext()) { count++; } Assert.AreEqual(100, count); }
public void Should_ReturnStateIdString_When_CallToString() { var en = new WuEnviroment("a", "a", "a", "a", TimeSpan.Zero, 10); StateDescription sd = new StateDescription(WuStateId.DownloadCompleted, "name", "desc", InstallerStatus.Busy, en); Assert.AreEqual(sd.ToString(), WuStateId.DownloadCompleted.ToString("G")); }
public void Should_ReturnTrue_When_CompareStateId() { var en = new WuEnviroment("a", "a", "a", "a", TimeSpan.Zero, 10); StateDescription sd = new StateDescription(WuStateId.Installing, "name", "", InstallerStatus.Busy, en); Assert.IsTrue(sd.Equals(WuStateId.Installing)); }
public void Should_NotAllowEmptyDisplayName_When_CreateStateDescription() { var en = new WuEnviroment("a", "a", "a", "a", TimeSpan.Zero, 10); try { StateDescription sd = new StateDescription(WuStateId.Installing, "", "", InstallerStatus.Busy, en); Assert.Fail("exception expected"); } catch (ArgumentException) { } try { StateDescription sd = new StateDescription(WuStateId.Installing, " ", "", InstallerStatus.Busy, en); Assert.Fail("exception expected"); } catch (ArgumentException) { } try { StateDescription sd = new StateDescription(WuStateId.Installing, null, "", InstallerStatus.Busy, en); Assert.Fail("exception expected"); } catch (ArgumentException) { } }
public void TestSetup() { var state = new StateDescription( WuDataContract.Enums.WuStateId.Ready, "mock", "mock", WuDataContract.Enums.InstallerStatus.Ready, new WuEnviroment("mock", "mock", "mock", "mock", TimeSpan.MinValue, 1)); var settings = new WuSettings(1, 1, 1, true, true); Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add <ServiceContractAttribute>(); _service = MoqFactory.Create <IWuRemoteService>(MockBehavior.Loose); _service.Setup(s => s.GetFQDN()).Returns("mock"); _service.Setup(s => s.GetWuStatus()).Returns(state); _service.Setup(s => s.GetSettings()).Returns(settings); _service.As <IChannel>(); var serviceFactory = MoqFactory.Create <WuRemoteServiceFactory>(MockBehavior.Loose); serviceFactory.Setup(f => f.GetInstance( It.IsAny <Binding>(), It.IsAny <EndpointAddress>(), It.IsAny <WuEndpoint.CallbackReceiver>())).Returns(_service.Object); _serviceFactory = serviceFactory.Object; }
public void RepositoryStateDescriptionEnumeratorTest() { DataRepository repository = new DataRepository(); StateDescription stateDescription = new StateDescription(new Catalog("Pride and Prejudice", "This is description", "Jane Austen"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null), "here"); repository.AddStateDescription(stateDescription); int count = 0; IEnumerator <object> enumerator = repository.GetAllStateDescriptions().GetEnumerator(); while (enumerator.MoveNext()) { count++; } Assert.AreEqual(1, count); StateDescription stateDescription2 = new StateDescription(new Catalog("Pride and Prejudice", "This is description", "Jane Austen"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null), "here"); repository.AddStateDescription(stateDescription2); count = 0; enumerator = repository.GetAllStateDescriptions().GetEnumerator(); while (enumerator.MoveNext()) { count++; } Assert.AreEqual(2, count); }
public StateDescriptionViewModel(StateDescription stateDescription) { Minimum = stateDescription.Minimum; Maximum = stateDescription.Maximum; Options = stateDescription.Options?.ToViewModels(); Pattern = stateDescription.Pattern; ReadOnly = stateDescription.ReadOnly; Step = stateDescription.Step; }
public void EqualsStateDescriptionMethodTest() { StateDescription stateDescription = new StateDescription(new Catalog("Pride and Prejudice", "This is description", "Jane Austen"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null), "here"); StateDescription stateDescription2 = new StateDescription(new Catalog("Pride and Prejudice", "This is description", "Jane Austen"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null), "here"); Assert.AreNotEqual(stateDescription, stateDescription2); StateDescription stateDescription3 = new StateDescription(new Catalog("Not okay", "Is it not?", "Not her"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null), "here"); stateDescription3.Code = stateDescription.Code; Assert.AreEqual(stateDescription, stateDescription3); }
public void StatedescriptionClonableTest() { string author = "Jane Austen"; Catalog book = new Catalog("Pride and Prejudice", "This is description", author); System.DateTimeOffset date = System.DateTimeOffset.Now; StateDescription stateDescription = new StateDescription(book, date, "here"); StateDescription stateDescription2 = (StateDescription)stateDescription.Clone(); Assert.AreEqual(stateDescription, stateDescription2); Assert.AreNotSame(stateDescription, stateDescription2); }
protected override void CacheDescription() { description = state.Description <StateDescription>(); title = description.title; summary = description.summary; titleContent.text = " " + title; titleContent.image = description.icon ? [IconSize.Small]; summaryContent.text = summary; Reposition(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { StateDescription state = value as StateDescription; Debug.Assert(state != null, $"{nameof(value)} should be castable to {typeof(StateDescription).Name}"); Debug.Assert(targetType == typeof(string)); if (state == null) { return(String.Empty); } return((state.Progress != null && !state.Progress.IsIndeterminate)?state.Progress.Percent.ToString() + "%":String.Empty); }
public void StatedescriptionConstructorTest() { string author = "Jane Austen"; Catalog book = new Catalog("Pride and Prejudice", "This is description", author); System.DateTimeOffset date = System.DateTimeOffset.Now; StateDescription stateDescription = new StateDescription(book, date, "here"); StateDescription stateDescription2 = new StateDescription(book, date, "here"); Assert.AreNotEqual(stateDescription.Code, stateDescription2.Code); Assert.AreEqual(stateDescription.Book, book); Assert.AreEqual(stateDescription.PurchaseDate, date); Assert.AreEqual(stateDescription.Location, "here"); }
public void EventClonableTest() { Person person = new Person("Mike", "Podolsky"); string author = "Jane Austen"; Catalog catalog = new Catalog("Pride and Prejudice", "This is description", author); StateDescription stateDescription = new StateDescription(catalog, System.DateTimeOffset.Now, "Here"); System.DateTimeOffset date = System.DateTimeOffset.Now; Event happening = new Event(person, stateDescription, Event.EventType.Borrow, date); Event happening2 = (Event)happening.Clone(); Assert.AreEqual(happening, happening2); Assert.AreNotSame(happening, happening2); }
public void ShowDescription(string s) { if (buttonsPanel.activeSelf == true) { buttonsPanel.SetActive(false); } else if (description.activeSelf == true) { description.SetActive(false); Time.timeScale = 1; } else { //descriptionInstance = Instantiate(description, GameObject.Find("Canvas").transform, instantiateInWorldSpace: false) as GameObject; //-------------- //Text title = GameObject.Find("Title").GetComponent<Text>(); //title.text = selectedObject.name; //-------------- // Button btn = GameObject.Find("Move").GetComponent<Button>(); // btn.onClick.AddListener(MoveCharacter); description.SetActive(true); Text date = GameObject.Find("Date").GetComponent <Text>(); date.text = time.ToString(); switch (s) { case ("action"): ActionDescription ad = new ActionDescription(); if (Simulation.lastActionPerformed != null) { ad.DescribeAction(Simulation.lastActionPerformed); } break; case ("worldState"): StateDescription sd = new StateDescription(); sd.DescribeWorldState(); break; case ("objectState"): DescribeObjectState(); break; default: break; } Time.timeScale = 0; } }
public void EventConstructorTest() { Person person = new Person("Mike", "Podolsky"); string author = "Jane Austen"; Catalog catalog = new Catalog("Pride and Prejudice", "This is description", author); StateDescription stateDescription = new StateDescription(catalog, System.DateTimeOffset.Now, "Here"); System.DateTimeOffset date = System.DateTimeOffset.Now; Event happening = new Event(person, stateDescription, Event.EventType.Borrow, date); Event happening2 = new Event(person, stateDescription, Event.EventType.Borrow, date); Assert.AreNotEqual(happening2.Code, happening.Code); Assert.AreEqual(person, happening.Causer); Assert.AreEqual(stateDescription, happening.BookState); Assert.AreEqual(date, happening.BorrowDate); }
public void Should_ContainSpecifiedValues_When_CreateStateDescription() { ProgressDescription pd = new ProgressDescription(); string name = "name"; string desc = "desc"; var insts = InstallerStatus.Busy; var en = new WuEnviroment("a", "a", "a", "a", TimeSpan.Zero, 10); StateDescription sd = new StateDescription(WuStateId.Installing, name, desc, insts, en, pd); Assert.AreEqual(name, sd.DisplayName); Assert.AreEqual(desc, sd.Description); Assert.AreEqual(WuStateId.Installing, sd.StateId); Assert.AreEqual(insts, sd.InstallerStatus); Assert.AreSame(pd, sd.Progress); Assert.AreSame(en, sd.Enviroment); }
public override int GetHashCode() { int hash = 1; if (State != 0) { hash ^= State.GetHashCode(); } if (StateDescription.Length != 0) { hash ^= StateDescription.GetHashCode(); } if (SuccessCount != 0) { hash ^= SuccessCount.GetHashCode(); } if (FailureCount != 0) { hash ^= FailureCount.GetHashCode(); } if (TotalCount != 0) { hash ^= TotalCount.GetHashCode(); } if (createTime_ != null) { hash ^= CreateTime.GetHashCode(); } if (updateTime_ != null) { hash ^= UpdateTime.GetHashCode(); } if (endTime_ != null) { hash ^= EndTime.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void FillData(DataContext dataContext) { // Person Data FIll Person person1 = new Person("Marcus", "Sagthon", "Michelles 42"); Person person2 = new Person("Ugho", "Olkag", "Putar 34"); Person person3 = new Person("Toby", "Vercer", "Palatem 51"); dataContext.Clients.Add(person1); dataContext.Clients.Add(person2); dataContext.Clients.Add(person3); // Catalog Data Fill Catalog catalog1 = new Catalog("Pride and Prejudice", "This is description1", "Jane Austen"); Catalog catalog2 = new Catalog("War and Peace", "This is description2", "Lew Tolstoj"); Catalog catalog3 = new Catalog("Metro 2033", "This is description3", "Dimitry Glukhovsky"); dataContext.Books.Add(1, catalog1); dataContext.Books.Add(2, catalog2); dataContext.Books.Add(3, catalog3); // StateDescription Data Fill StateDescription stateDescription1 = new StateDescription(catalog1, System.DateTimeOffset.Now, "Somewhere"); StateDescription stateDescription2 = new StateDescription(catalog2, System.DateTimeOffset.Now, "There"); StateDescription stateDescription3 = new StateDescription(catalog3, System.DateTimeOffset.Now, "Here"); dataContext.Descriptions.Add(stateDescription1); dataContext.Descriptions.Add(stateDescription2); dataContext.Descriptions.Add(stateDescription3); //Event Data Fill System.DateTimeOffset date1 = System.DateTimeOffset.Now; Event happening1 = new Event(person1, stateDescription1, Event.EventType.Borrow, date1); Event happening2 = new Event(person2, stateDescription1, Event.EventType.Return, date1); Event happening3 = new Event(person3, stateDescription1, Event.EventType.Borrow, date1); dataContext.Transactions.Add(happening1); dataContext.Transactions.Add(happening2); dataContext.Transactions.Add(happening3); }
public void RepositoryStateDescriptionUPDATETest() { DataRepository repository = new DataRepository(); StateDescription stateDescription = new StateDescription(new Catalog("Pride and Prejudice", "This is description", "Jane Austen"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null), "here"); repository.AddStateDescription(stateDescription); StateDescription stateDescription2 = new StateDescription(new Catalog("Pride and Prejudice", "This is description", "Jane Austen"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null), "here"); stateDescription2.Code = stateDescription.Code; repository.UpdateStateDescription(stateDescription2); Assert.AreEqual(stateDescription2, repository.GetStateDescriptionByCode(stateDescription2.Code)); StateDescription stateDescription3 = new StateDescription(new Catalog("Pride and Prejudice", "This is description", "Jane Austen"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null), "here"); stateDescription3.Code = stateDescription.Code; stateDescription3.Location = "test"; repository.UpdateStateDescription(stateDescription3); Assert.AreEqual("test", repository.GetStateDescriptionByCode(stateDescription.Code).Location); }
public void RepositoryStateDescriptionUpdateMultipleTest() { DataRepository dr = new DataRepository(); List <StateDescription> stateDescriptionsToUpdate = new List <StateDescription>(); for (int i = 0; i < 100; i++) { StateDescription stateDescription = new StateDescription(new Catalog("Pride and Prejudice", "This is description", "Jane Austen"), System.DateTimeOffset.ParseExact("28/01/2019", "dd/MM/yyyy", null).AddDays(i), "here"); if (i % 8 == 0) { stateDescriptionsToUpdate.Add(stateDescription); } dr.AddStateDescription(stateDescription); } int count = 0; foreach (StateDescription stateDescription in stateDescriptionsToUpdate) { count += 1; stateDescription.Location = "test " + count; dr.UpdateStateDescription(stateDescription); } foreach (StateDescription stateDescription in stateDescriptionsToUpdate) { Assert.AreEqual(stateDescription.Location, dr.GetStateDescriptionByCode(stateDescription.Code).Location); } count = 0; IEnumerator <StateDescription> enumerator = dr.GetAllStateDescriptions().GetEnumerator(); while (enumerator.MoveNext()) { count++; } Assert.AreEqual(100, count); }
StateDescription get(State start) { if (cached[start.l1 + 1, start.r1 + 1, start.r2 + 1]) return cache[start.l1 + 1, start.r1 + 1, start.r2 + 1]; int bestMoves = int.MaxValue / 2; int bestBy = -1; cache[start.l1 + 1, start.r1 + 1, start.r2 + 1] = new StateDescription(bestMoves, bestBy); cached[start.l1 + 1, start.r1 + 1, start.r2 + 1] = true; if (start.l2 >= start.r2 || (start.l1 > start.r2 && start.l2 >= start.r1) || (start.l2 > start.r1 && start.l1 >= start.r2)) { bestMoves = 0; } else { for (int i = start.l2; i < start.r2; ++i) { State s1; State s2; start.doMove(i, out s1, out s2); int curMoves = 1 + Math.Max(get(s1).numMoves, get(s2).numMoves); if (curMoves < bestMoves) { bestMoves = curMoves; bestBy = i; } } } StateDescription res = new StateDescription(bestMoves, bestBy); cache[start.l1 + 1, start.r1 + 1, start.r2 + 1] = res; // Console.WriteLine(start.l2 + " " + start.l1 + " " + start.r1 + " " + start.r2 + " " + res.numMoves); return res; }
/// <summary> /// Sets the state description. /// </summary> /// <param name="item">The item.</param> /// <param name="stateDescription">The state description.</param> /// <returns></returns> public static Item SetStateDescription(this Item item, StateDescription stateDescription) { item.StateDescription = stateDescription; return item; }
public static DataContext Deserialize(string filename) { DataContext dataContext = new DataContext(); SerializeHelper helper = new SerializeHelper(); string data = System.IO.File.ReadAllText(filename); var dataList = data.Split('\n'); for (int i = 0; i < dataList.Length; i++) { if (!string.IsNullOrEmpty(dataList[i])) { var splittedLine = dataList[i].Split(','); Type type = Type.GetType(splittedLine[0]); if (type != null) { object obj = Activator.CreateInstance(type); switch (helper.typeDict[type]) { case 0: Person person = (Person)obj; if (!person.Deserialize(splittedLine, helper)) { break; } helper.PeopleDictionary.Add(splittedLine[1], person); dataContext.PeopleCatalog.Add(person); break; case 1: Reader reader = (Reader)obj; if (!reader.Deserialize(splittedLine, helper)) { break; } helper.PeopleDictionary.Add(splittedLine[1], reader); dataContext.PeopleCatalog.Add(reader); break; case 2: Author author = (Author)obj; if (!author.Deserialize(splittedLine, helper)) { break; } helper.PeopleDictionary.Add(splittedLine[1], author); dataContext.PeopleCatalog.Add(author); break; case 3: Item item = (Item)obj; if (!item.Deserialize(splittedLine, helper)) { break; } helper.ItemsDictionary.Add(splittedLine[1], item); dataContext.ItemsCatalog.Add(item.Id, item); break; case 4: Book book = (Book)obj; if (!book.Deserialize(splittedLine, helper)) { break; } helper.ItemsDictionary.Add(splittedLine[1], book); dataContext.ItemsCatalog.Add(book.Id, book); break; case 5: StateDescription stateDescription = (StateDescription)obj; if (!stateDescription.Deserialize(splittedLine, helper)) { break; } helper.StatesDictionary.Add(splittedLine[1], stateDescription); dataContext.StatesCatalog.Add(stateDescription); break; case 6: BookDescription bookDescription = (BookDescription)obj; if (!bookDescription.Deserialize(splittedLine, helper)) { break; } helper.StatesDictionary.Add(splittedLine[1], bookDescription); dataContext.StatesCatalog.Add(bookDescription); break; case 7: Event ev = (Event)obj; if (!ev.Deserialize(splittedLine, helper)) { break; } dataContext.EventsCatalog.Add(ev); break; case 8: Rental rental = (Rental)obj; if (!rental.Deserialize(splittedLine, helper)) { break; } dataContext.EventsCatalog.Add(rental); break; } } } } return(dataContext); }
public ReturnEvent(Person causer, StateDescription bookState, DateTimeOffset date) : base(causer, bookState, date) { }
private void SetState(string state, string desc) { if (IsLoaded) { #region Show Toast State Mark if (string.IsNullOrEmpty(state)) { State.Text = string.Empty; State.Hide(); } else if (state.Equals("Successed", StringComparison.CurrentCultureIgnoreCase) || state.Equals("Successes", StringComparison.CurrentCultureIgnoreCase) || state.Equals("Succeed", StringComparison.CurrentCultureIgnoreCase)) { State.Text = "\uE10B"; State.Foreground = Theme.AccentBrush; State.Show(); } else if (state.Equals("Failed", StringComparison.CurrentCultureIgnoreCase)) { State.Text = "\uE10A"; State.Foreground = Theme.ErrorBrush; State.Show(); } else { State.Text = string.Empty; State.Hide(); } #endregion #region Show Toast State Description Mark if (string.IsNullOrEmpty(desc)) { StateDescription.Text = string.Empty; StateDescription.Hide(); } else if (desc.Equals("Public", StringComparison.CurrentCultureIgnoreCase)) { StateDescription.Text = "\uE1F7"; StateDescription.Foreground = State.Foreground; StateDescription.Show(); } else if (desc.Equals("Private", StringComparison.CurrentCultureIgnoreCase)) { StateDescription.Text = "\uE1F6"; StateDescription.Foreground = State.Foreground; StateDescription.Show(); } else { StateDescription.Text = string.Empty; StateDescription.Hide(); } #endregion if (string.IsNullOrEmpty(state) && string.IsNullOrEmpty(desc)) { StateMark.Hide(); } else { StateMark.Show(); } } }
public static StateDescriptionViewModel ToViewModel(this StateDescription stateDescription) { return(stateDescription == null ? null : new StateDescriptionViewModel(stateDescription)); }
protected override async Task <ICommandResult> Handle(DescriptionCommand command) { DescriptionCommandResult DescriptionCommandResult = new DescriptionCommandResult(); if (!command.IsStateDescription && !command.IsCityDescription) { var countryDescription = _countryDescriptionRepository.GetByCountryId(command.Country.Id); if (countryDescription != null) { countryDescription.Description = command.Description; _countryDescriptionRepository.Save(countryDescription); } else { var countryDesc = new CountryDescription { CountryId = command.Country.Id, Description = command.Description, CreatedBy = command.CreatedBy, ModifiedBy = command.CreatedBy, CreatedUtc = DateTime.UtcNow, IsEnabled = true, UpdatedBy = command.CreatedBy, UpdatedUtc = DateTime.UtcNow }; _countryDescriptionRepository.Save(countryDesc); } } else if (!command.IsCountryDescription && !command.IsStateDescription) { var cityDescription = _cityDescriptionRepository.GetBycityId(command.City.Id); if (cityDescription != null) { cityDescription.Description = command.Description; cityDescription.UpdatedUtc = DateTime.UtcNow; cityDescription.ModifiedBy = command.CreatedBy; _cityDescriptionRepository.Save(cityDescription); } else { var cityDesc = new CityDescription { CityId = command.City.Id, Description = command.Description, CreatedBy = command.CreatedBy, ModifiedBy = command.CreatedBy, CreatedUtc = DateTime.UtcNow, IsEnabled = true, UpdatedBy = command.CreatedBy, UpdatedUtc = DateTime.UtcNow }; _cityDescriptionRepository.Save(cityDesc); } } else { var stateDescription = new StateDescription { StateId = command.StateId, Description = command.Description, CreatedBy = command.CreatedBy, ModifiedBy = command.CreatedBy, CreatedUtc = DateTime.UtcNow, IsEnabled = true, UpdatedBy = command.CreatedBy, UpdatedUtc = DateTime.UtcNow }; _stateDescriptionRepository.Save(stateDescription); } return(DescriptionCommandResult); }