public void TestDataBindingSubList() { var boundDataGridView = new BoundDataGridView { BindingContext = new BindingContext(), DataSource = new BindingListSource(), }; using (boundDataGridView) { var columnIds = new[] { PropertyPath.Root, PropertyPath.Parse("Sequence"), PropertyPath.Parse("AminoAcidsList!*.Code"), PropertyPath.Parse("Molecule!*"), }; var viewSpec = new ViewSpec() .SetColumns(columnIds.Select(id => new ColumnSpec().SetPropertyPath(id))) .SetSublistId(PropertyPath.Parse("AminoAcidsList!*")); var viewInfo = new ViewInfo(new DataSchema(), typeof (LinkValue<Peptide>), viewSpec); // ReSharper disable once UseObjectOrCollectionInitializer var innerList = new BindingList<LinkValue<Peptide>>(); innerList.Add(new LinkValue<Peptide>(new Peptide("AD"), null)); ((BindingListSource)boundDataGridView.DataSource).SetViewContext(new TestViewContext(viewInfo.DataSchema, new[]{new RowSourceInfo(innerList, viewInfo)})); Assert.AreEqual(2, boundDataGridView.Rows.Count); innerList.Add(new LinkValue<Peptide>(new Peptide("TISE"), null)); Assert.AreEqual(6, boundDataGridView.Rows.Count); } }
public void ProjectFilesShouldCopyAllReferences() { var root = Extensions.GetSolutionRoot(); var projectsToTest = new[] { "Shapeshifter.WindowsDesktop", "Shapeshifter.WindowsDesktop.Native" }; foreach (var project in projectsToTest) { var projectPath = Path.Combine( root, project, $"{project}.csproj"); var document = new XmlDocument(); document.LoadXml( File.ReadAllText(projectPath)); var namespaceManager = new XmlNamespaceManager(document.NameTable); namespaceManager.AddNamespace("default", "http://schemas.microsoft.com/developer/msbuild/2003"); var references = document.SelectNodes("//default:Reference", namespaceManager); Assert.IsNotNull(references); Assert.AreNotEqual(0, references.Count); foreach (XmlNode reference in references) { var privateNode = reference.SelectSingleNode("./default:Private", namespaceManager); Assert.IsNotNull(privateNode); Assert.AreEqual("True", privateNode.InnerText); } } }
public void InTest() { Expect("Test".In("0", "Test", "1")); Expect("Test".In("0", "TEST", "1"), False); var arr = new[] { 0, 1, 2 }; Expect(1.In(arr)); Expect(100.In(arr), False); }
public void Nodes_SomeList_Same() { var block = MockRepository.GenerateStub<IBlock>(); var nodes = new[] { MockRepository.GenerateStub<ISyntacticNode>(), MockRepository.GenerateStub<ISyntacticNode>() }; var blockNode = new BlockSyntacticNode(block, nodes); Assert.That(blockNode.Nodes, Is.SameAs(nodes)); }
public static string BreakUpCamelCase(string fieldName) { var patterns = new[] { "([a-z])([A-Z])", "([0-9])([a-zA-Z])", "([a-zA-Z])([0-9])" }; var output = patterns.Aggregate(fieldName, (current, pattern) => Regex.Replace(current, pattern, "$1 $2", RegexOptions.IgnorePatternWhitespace)); return output.Replace('_', ' '); }
public void ShouldSearchStationOnExecution() { const string StationName = "some station"; var resultingStations = new[] { new Station() }; A.CallTo(() => this.transportService.GetLocations(StationName)).Returns(resultingStations); var doWorkEventArgs = new DoWorkEventArgs(new SearchStationAsyncCommand.BackgroundWorkerArgs(this.transportService, StationName)); this.testee.Execute(doWorkEventArgs); doWorkEventArgs.Result.Should().Be(resultingStations); }
public override HttpRequestItem BuildRequest() { var url = string.Format(ApiUrls.StatusNotify, Session.BaseUrl, Session.PassTicket); var obj = new { Session.BaseRequest, Code = 3, FromUserName = Session.UserToken["UserName"], ToUserName = Session.UserToken["UserName"], ClientMsgId = Timestamp }; var req = new HttpRequestItem(HttpMethodType.Post, url) { RawData = JsonConvert.SerializeObject(obj), ContentType = HttpConstants.JsonContentType, }; return req; }
public override HttpRequestItem BuildRequest() { var url = string.Format(ApiUrls.WebwxInit, Session.BaseUrl, Session.PassTicket, Session.Skey, Timestamp); var req = new HttpRequestItem(HttpMethodType.Post, url); var obj = new { Session.BaseRequest }; /* { "BaseRequest": { "DeviceId": "e650946746417762", "Skey": "@crypt_c498484a_1d7a344b3232380eb1aa33c16690399a", "Sid": "PhHAnhCRcFDCA219", "Uin": "463678295" } } */ req.RawData = JsonConvert.SerializeObject(obj); req.ContentType = HttpConstants.JsonContentType; return req; }
public void ExplicitAddTextSuccessful() { // ARRANGE dialogService .Setup(mock => mock.ShowDialog<AddTextDialog>(viewModel, It.IsAny<AddTextDialogViewModel>())) .Returns(true) .Callback((INotifyPropertyChanged ownerViewModel, AddTextDialogViewModel addTextDialogViewModel) => addTextDialogViewModel.Text = "Some text"); var expected = new[] { "Some text" }; // ACT viewModel.ExplicitShowDialogCommand.Execute(null); // ASSERT Assert.That(viewModel.Texts, Is.EqualTo(expected)); }
public ActionResult GetMenus() { var icons = new[] { "fa-th", "fa-desktop", "fa-table", "fa-bar-chart-o", "fa-pencil-square-o", "fa-picture-o", "fa-calendar", "fa-credit-card", "fa-hdd-o", "fa-tasks" }; var functions = SecurityContract.Functions.Where(p => !p.IsLocked && !p.IsCustom && !p.IsAjax && p.PlatformToken == PlatformToken.Mvc) .OrderBy(p => p.OrderNo) .ToList(); int i = 0; var menus = functions.Where(p => p.IsController).Select(p => { return new TreeNode() { Id = p.Id, Text = p.Name, IconCls = icons[i++ % icons.Count()], Url = Url.Action(p.Action, p.Controller, new { area = p.Area }), Children = functions.Where( m => m.Controller == p.Controller && m.Area == p.Area && !m.IsController && m.IsMenu) .Select(m => { string url = Url.Action(m.Action, m.Controller, new { area = m.Area }); if (url == "/") url = ""; return new TreeNode() { Id = m.Id, Text = m.Name, IconCls = "", Url = url, }; }).ToList() }; }).ToList(); return Json(menus); }
public void ChangesInLayersBubbleUpToMap() { var coverage = new RegularGridCoverage(10, 10, 1, 1); var layer = new RegularGridCoverageLayer { Coverage = coverage }; int callCount = 0; var senders = new object[] {coverage, layer}; var propertyNames = new[] {"Name", "RenderRequired"}; ((INotifyPropertyChanged)layer).PropertyChanged += (sender,args)=> { Assert.AreEqual(senders[callCount], sender); Assert.AreEqual(propertyNames[callCount], args.PropertyName); callCount++; }; //change the name of the layer coverage.Name = "new name"; //should result in property changed of map Assert.AreEqual(2, callCount); }
public void ShowRangeBarInForm() { var rangeBar = new RangeBar(); lb = new ListBox(); var form = new Form(); lb.Location = new Point(40, 40); form.Controls.Add(rangeBar); form.Controls.Add(lb); var histogram = new[] {11, 21, 31, 35}; var handleValues = new double[] {10, 20, 30, 40, 50}; doubleValues = new BindingList<double>(); foreach (double d in handleValues) { doubleValues.Add(d); } doubleValues.AllowEdit = true; lb.DataSource = doubleValues; var colors = new[] {Color.Red, Color.Green, Color.Yellow, Color.Blue}; rangeBar.SetHandles(handleValues, colors); rangeBar.Histogram = histogram; rangeBar.UserDraggingHandle += rangeBar_UserDraggingHandle; WindowsFormsTestHelper.ShowModal(form); }
public void ConversionToStringWithNullObjIsNull() { var obj = new { Id = (ObjectId)null }; string implicitString = obj.Id; Assert.Null(implicitString); }
public void AddRangeAddsAllItems() { var collection = new[] { _con1, _con2, _con3 }; _containerInfo.AddChildRange(collection); Assert.That(_containerInfo.Children, Is.EquivalentTo(collection)); }
public void MultipleInstancesTest() { InpcDerrivedClass[] objects1 = new[] { new InpcDerrivedClass(), new InpcDerrivedClass(), new InpcDerrivedClass(), new InpcDerrivedClass(), new InpcDerrivedClass() }; InpcBasicClass[] objects2 = new[] { new InpcBasicClass(), new InpcBasicClass(), new InpcBasicClass(), new InpcBasicClass(), new InpcBasicClass() }; int[] firedEvents1 = new int[5]; int[] firedEvents2 = new int[5]; for (int i = 0; i < 5; i++) { int j = i; ((INotifyPropertyChanged)objects1[i]).PropertyChanged += (s, e) => firedEvents1[j]++; ((INotifyPropertyChanged)objects2[i]).PropertyChanged += (s, e) => firedEvents2[j]++; } for (int i = 0; i < 5; i++) { objects1[i].AutoProperty = 2; objects2[i].AutoProperty = 3; } for (int i = 0; i < 5; i++) { Assert.AreEqual(1, firedEvents1[i]); Assert.AreEqual(1, firedEvents2[i]); } }
private static IDocument AddSetPropertyMethod(this IDocument document, SyntaxAnnotation classAnnotation) { var semanticModel = document.GetSemanticModel(); var classDeclaration = document.GetAnnotatedNode<ClassDeclarationSyntax>(classAnnotation); var classSymbol = (INamedTypeSymbol)semanticModel.GetDeclaredSymbol(classDeclaration); var interfaceSymbol = semanticModel.Compilation.GetTypeByMetadataName(InterfaceName); var propertyChangedEventSymbol = (IEventSymbol)interfaceSymbol.GetMembers("PropertyChanged").Single(); var propertyChangedEvent = classSymbol.FindImplementationForInterfaceMember(propertyChangedEventSymbol); // Because the SetProperty<T>(ref T, T, string) method contains statements, we need to add the following // namespaces manually. var globalNamespace = semanticModel.Compilation.GlobalNamespace; var namespaces = new[] { globalNamespace.FindNamespace("System.ComponentModel"), globalNamespace.FindNamespace("System.Collections.Generic") }; var setPropertyMethod = classSymbol.FindSetPropertyMethod(semanticModel.Compilation); if (setPropertyMethod == null) { // There isn't an existing SetProperty<T>(ref T, T, string) method, so let's create one. var beforeThisLocation = propertyChangedEvent != null ? propertyChangedEvent.Locations.FirstOrDefault() : null; var codeGenResult = GenerateSetPropertyMethod(semanticModel.Compilation) .AddMethodTo(classSymbol, document.Project.Solution, new CodeGenerationOptions( beforeThisLocation: beforeThisLocation, additionalImports: namespaces)); return codeGenResult; } return document; }
public void TestPivotResultsThenIsotopeLabel() { var assembly = typeof (LiveReportPivotTest).Assembly; XmlSerializer documentSerializer = new XmlSerializer(typeof(SrmDocument)); // ReSharper disable once AssignNullToNotNullAttribute var document = (SrmDocument)documentSerializer.Deserialize( assembly.GetManifestResourceStream(typeof(ReportSpecConverterTest), "silac_1_to_4.sky")); XmlSerializer reportSerializer = new XmlSerializer(typeof(ReportOrViewSpecList)); // ReSharper disable once AssignNullToNotNullAttribute var views = (ReportOrViewSpecList) reportSerializer.Deserialize( assembly.GetManifestResourceStream(typeof(ReportSpecConverterTest), "LiveReportPivots.skyr")); var view = views.First(reportSpec => reportSpec.Name == "ResultSummaryPivotResultsThenLabelType").ViewSpec; var bindingListSource = new BindingListSource(); var documentContainer = new MemoryDocumentContainer(); Assert.IsTrue(documentContainer.SetDocument(document, null)); var dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT); bindingListSource.SetViewContext(new DocumentGridViewContext(dataSchema), new ViewInfo(dataSchema, typeof(Precursor), view)); var expectedColumnNames = new[] { "PeptideSequence", "Chromatograms Replicate", "Chromatograms PeptideRetentionTime", "light IsotopeLabelType", "light MeanTotalArea", "light Chromatograms TotalArea", "heavy IsotopeLabelType", "heavy MeanTotalArea", "heavy Chromatograms TotalArea", }; var actualColumnNames = bindingListSource.GetItemProperties(null) .Cast<PropertyDescriptor>() .Select(pd => pd.DisplayName) .ToArray(); CollectionAssert.AreEqual(expectedColumnNames, actualColumnNames); }
public async Task<IHttpActionResult> GetUserInfo() { var theUser = await UserContract.UserInfos.SingleOrDefaultAsync(p => p.Id == OperatorId); if (theUser == null) return Json(new ApiResult(OperationResultType.QueryNull, "用户不存在")); var userData = new { theUser.Id, theUser.SysUser.NickName, theUser.Signature, theUser.HeadPic, theUser.Sex, theUser.BirthDay }; return Json(new ApiResult("获取成功", userData)); }
/// <summary> /// The set color. /// </summary> /// <param name = "channel"> /// The channel. /// </param> /// <param name = "intensity"> /// The intensity. /// </param> public virtual void SetColor(Channel channel, byte intensity) { if (channel == null) { return; } var channelName = channel.Name; var redChannel = this.RedChannel; if (redChannel != null && channelName == redChannel.Name) { this._red = intensity; } else { var greenChannel = this.GreenChannel; if (greenChannel != null && channelName == greenChannel.Name) { this._green = intensity; } else { var blueChannel = this.BlueChannel; if (blueChannel != null && channelName == blueChannel.Name) { this._blue = intensity; } } } var alpha = new[] { _red, _green, _blue }.Max(); this.ChannelColor = Color.FromArgb(alpha, this._red, this._green, this._blue); }
public IOModule() { var types = new[]{typeof (TreeListEditorsModuleBase), typeof (ModelArtifactStateModule)}; foreach (var type in types) { RequiredModuleTypes.Add(type); } }
public void RemoveRangeDoesNotRemoveUntargetedMembers() { var collection = new[] { _con1, _con2, new ContainerInfo() }; _containerInfo.AddChildRange(collection); _containerInfo.AddChild(_con3); _containerInfo.RemoveChildRange(collection); Assert.That(_containerInfo.Children, Does.Contain(_con3)); }
private void RefreshChanges() { var region = new Region(Rectangle.Empty); Rectangle rectDockArea = FullPanelEdge ? DockPanel.DockArea : DockPanel.DocumentWindowBounds; rectDockArea = RectangleToClient(DockPanel.RectangleToScreen(rectDockArea)); if (ShouldPanelIndicatorVisible(DockState.DockLeft)) { PanelLeft.Location = new Point(rectDockArea.X + _PanelIndicatorMargin, rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2); PanelLeft.Visible = true; region.Union(PanelLeft.Bounds); } else PanelLeft.Visible = false; if (ShouldPanelIndicatorVisible(DockState.DockRight)) { PanelRight.Location = new Point(rectDockArea.X + rectDockArea.Width - PanelRight.Width - _PanelIndicatorMargin, rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2); PanelRight.Visible = true; region.Union(PanelRight.Bounds); } else PanelRight.Visible = false; if (ShouldPanelIndicatorVisible(DockState.DockTop)) { PanelTop.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelTop.Width) / 2, rectDockArea.Y + _PanelIndicatorMargin); PanelTop.Visible = true; region.Union(PanelTop.Bounds); } else PanelTop.Visible = false; if (ShouldPanelIndicatorVisible(DockState.DockBottom)) { PanelBottom.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelBottom.Width) / 2, rectDockArea.Y + rectDockArea.Height - PanelBottom.Height - _PanelIndicatorMargin); PanelBottom.Visible = true; region.Union(PanelBottom.Bounds); } else PanelBottom.Visible = false; if (ShouldPanelIndicatorVisible(DockState.Document)) { Rectangle rectDocumentWindow = RectangleToClient(DockPanel.RectangleToScreen(DockPanel.DocumentWindowBounds)); PanelFill.Location = new Point(rectDocumentWindow.X + (rectDocumentWindow.Width - PanelFill.Width) / 2, rectDocumentWindow.Y + (rectDocumentWindow.Height - PanelFill.Height) / 2); PanelFill.Visible = true; region.Union(PanelFill.Bounds); } else PanelFill.Visible = false; if (ShouldPaneDiamondVisible()) { var rect = RectangleToClient(DockPane.RectangleToScreen(DockPane.ClientRectangle)); PaneDiamond.Location = new Point(rect.Left + (rect.Width - PaneDiamond.Width) / 2, rect.Top + (rect.Height - PaneDiamond.Height) / 2); PaneDiamond.Visible = true; using (var graphicsPath = PaneIndicator.DisplayingGraphicsPath.Clone() as GraphicsPath) { var pts = new[] { new Point(PaneDiamond.Left, PaneDiamond.Top), new Point(PaneDiamond.Right, PaneDiamond.Top), new Point(PaneDiamond.Left, PaneDiamond.Bottom) }; using (var matrix = new Matrix(PaneDiamond.ClientRectangle, pts)) { graphicsPath.Transform(matrix); } region.Union(graphicsPath); } } else PaneDiamond.Visible = false; Region = region; }
public void RemoveRangeRemovesAllIndicatedItems() { var collection = new[] { _con1, _con2, new ContainerInfo() }; _containerInfo.AddChildRange(collection); _containerInfo.RemoveChildRange(collection); Assert.That(_containerInfo.Children, Does.Not.Contains(collection[0]).And.Not.Contains(collection[1]).And.Not.Contains(collection[2])); }