static Data ReadFieldData(string fname) { var d = new Data(); var rows = new List<double[]>(); var labels = new List<string>(); using (GenericParser parser = new GenericParser()) { parser.SetDataSource(fname); parser.ColumnDelimiter = ','; parser.FirstRowHasHeader = false; parser.TextQualifier = '\"'; while(parser.Read()) { rows.Add(StringKernalFunction(parser[0].Trim())); labels.Add(parser[1]); } } d.Features = rows.ToArray(); d.Labels = labels.ToArray(); return d; }
public void NoChangesDoesNotTriggerUpdate() { var original = new Data(); var editRequest = new EditDataRequest(); Assert.False(editRequest.TryUpdateFromMe(original)); }
public void NoChangesWhenValueDoesNotChange() { var original = new Data(); original.Header = "hello"; var editRequest = new EditDataRequest(); editRequest.Header = "hello"; Assert.False(editRequest.TryUpdateFromMe(original)); }
public void UpdatingChildPropertyButNoChildValues() { var original = new Data(); original.Child = new ChildData(); var editRequest = new EditDataRequest(); editRequest.Child = new EditChildDataRequest(); bool wasUpdated = editRequest.TryUpdateFromMe(original); Assert.That(wasUpdated, Is.False); }
public void UpdatesToCollectionTest() { var original = new Data(); original.Custom = new List<string>() { "hello" }; var editRequest = new EditDataRequest(); editRequest.Custom = new List<string>() { "hello", "world" }; bool wasUpdated = editRequest.TryUpdateFromMe(original); Assert.That(wasUpdated, Is.True); }
public void UpdatingASingleProperty() { var original = new Data(); original.Header = "hello"; var editRequest = new EditDataRequest(); editRequest.Header = "new val"; bool thing = editRequest.TryUpdateFromMe(original); Assert.That(thing, Is.True); Assert.That(original.Header, Is.EqualTo("new val")); }
public void UpdatingChildPropertyAndChildValues() { var original = new Data(); original.Child = new ChildData(); var editRequest = new EditDataRequest(); var editChildDataRequest = new EditChildDataRequest(); editChildDataRequest.Name = "new name"; editRequest.Child = editChildDataRequest; bool wasUpdated = editRequest.TryUpdateFromMe(original); Assert.That(wasUpdated, Is.True); Assert.That(original.Child.Name, Is.EqualTo("new name")); }