public void PrepareEZLayout_KeyCategoryWithGlyphs(string keyCode, string expectedLabel, KeyDisplayType expectedDisplayType, KeyCategory expectedCategory, bool expectedIsGlyph) { // Arrange var ergodoxKey = new ErgodoxKey() { GlowColor = "", Code = keyCode }; ErgodoxLayout ergodoxLayout = InitializeDataTree(); ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey); EZLayout ezLayoutResult; // Act var ezLayoutMaker = new EZLayoutMaker(); ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout); // Assert Assert.Single(ezLayoutResult.EZLayers); Assert.Single(ezLayoutResult.EZLayers.First().EZKeys); var keyResult = ezLayoutResult.EZLayers.First().EZKeys.First(); Assert.Equal(expectedLabel, keyResult.Label.Content); Assert.Equal(expectedIsGlyph, keyResult.Label.IsGlyph); Assert.Equal(expectedDisplayType, keyResult.DisplayType); Assert.Equal(expectedCategory, keyResult.KeyCategory); }
public void PrepareEZLayout_InitializeEZLayer(int expectedIndex, string expectedTitle, string expectedColor) { // Arrange var ergodoxLayer = new ErgodoxLayer() { Color = expectedColor, Title = expectedTitle, Position = expectedIndex, Keys = new List <ErgodoxKey>() }; ErgodoxLayout ergodoxLayout = new ErgodoxLayout { Title = "", HashId = "", Revision = new Revision { HashId = HashId, Layers = new List <ErgodoxLayer> { ergodoxLayer } } }; EZLayout ezLayoutResult; // Act var ezLayoutMaker = new EZLayoutMaker(); ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout); // Assert Assert.Single(ezLayoutResult.EZLayers); Assert.Equal(expectedTitle, ezLayoutResult.EZLayers.First().Name); Assert.Equal(expectedIndex, ezLayoutResult.EZLayers.First().Index); Assert.Equal(expectedColor, ezLayoutResult.EZLayers.First().Color); }
public void PrepareEZLayout_KeyCategoryShortcuts(string keyCode, string command, string expectedLabel, KeyCategory expectedCategory) { // Arrange var ergodoxKey = new ErgodoxKey() { GlowColor = "", Code = keyCode, Command = command }; ErgodoxLayout ergodoxLayout = InitializeDataTree(); ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey); EZLayout ezLayoutResult; // Act var ezLayoutMaker = new EZLayoutMaker(); ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout); // Assert Assert.Single(ezLayoutResult.EZLayers); Assert.Single(ezLayoutResult.EZLayers.First().EZKeys); var keyResult = ezLayoutResult.EZLayers.First().EZKeys.First(); Assert.Equal(expectedLabel, keyResult.Label.Content); Assert.Null(keyResult.Modifier); Assert.Equal(expectedCategory, keyResult.KeyCategory); }
public void PrepareEZLayout_ProcessModifiers(bool leftAlt, bool leftCtrl, bool leftShift, bool leftWin, bool rightAlt, bool rightCtrl, bool rightShift, bool rightWin, string expectedSubLabel, KeyDisplayType expectedDisplayType) { // Arrange var modifiers = new ErgodoxModifiers { LeftAlt = leftAlt, LeftCtrl = leftCtrl, LeftShift = leftShift, LeftWin = leftWin, RightAlt = rightAlt, RightCtrl = rightCtrl, RightShift = rightShift, RightWin = rightWin }; var ergodoxKey = new ErgodoxKey() { GlowColor = "", Code = "KC_A", Modifiers = modifiers }; ErgodoxLayout ergodoxLayout = InitializeDataTree(); ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey); EZLayout ezLayoutResult; // Act var ezLayoutMaker = new EZLayoutMaker(); ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout); // Assert Assert.Single(ezLayoutResult.EZLayers); Assert.Single(ezLayoutResult.EZLayers.First().EZKeys); var keyResult = ezLayoutResult.EZLayers.First().EZKeys.First(); Assert.Equal("A", keyResult.Label.Content); if (expectedDisplayType == KeyDisplayType.SimpleLabel) { Assert.Null(keyResult.Modifier); } else { Assert.Equal(expectedSubLabel, keyResult.Modifier.Content); Assert.False(keyResult.Modifier.IsGlyph); } Assert.Equal(expectedDisplayType, keyResult.DisplayType); }
public async void GetAllCitiesTest() { var result = (await _tenantRepository.GetAllCitiesAsync(_tenantId)); Assert.NotNull(result); Assert.Single(result); Assert.Equal("HYD", result[0].CityCode); Assert.Equal("Hyderabad", result[0].CityName); }
public void FindSeatsTests_BookingId_NotNull() { var result = _findRoomsController.FindRooms("tenantName", 1, 1); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <IEnumerable <BookingModel> >(viewResult.Model); Assert.Single(model); }
public void GetMountedPartitionsInfoTest_Good() { var res = _good.GetMountedPartitionsInfo().ToList(); Assert.Single(res); var disk = res.First(); Assert.Equal("/dev/mmcblk0p1", disk.Name); Assert.Equal(14767, disk.MemoryInMB); Assert.Equal(1658, disk.UsedMemoryInMB); }
public void Build_IgnoreProperty_Success() { var bindingConfig = new BindingConfig(); bindingConfig.IgnoreSourceField(nameof(SourceWithRecursion.Id)); var mappingMemberBuilder = new MappingMemberBuilder(new MappingBuilderConfigStub(bindingConfig)); List <MappingMemberPath> members = mappingMemberBuilder.Build(new TypePair(typeof(SourceWithRecursion), typeof(TargetWithRecursion))); XAssert.Single(members); }
public void PrepareEZLayout_KeyCategoryLayerShortcut(string keyCode, string command, string expectedLabel, string expectedSubLabel, KeyDisplayType expectedDisplayType, KeyCategory expectedCategory) { // Arrange var ergodoxKey = new ErgodoxKey() { GlowColor = "", Code = keyCode, Command = command, Layer = 1 }; ErgodoxLayout ergodoxLayout = InitializeDataTree(); ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey); EZLayout ezLayoutResult; // Act var ezLayoutMaker = new EZLayoutMaker(); ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout); // Assert Assert.Single(ezLayoutResult.EZLayers); Assert.Single(ezLayoutResult.EZLayers.First().EZKeys); var keyResult = ezLayoutResult.EZLayers.First().EZKeys.First(); Assert.Equal(expectedLabel, keyResult.Label.Content); if (expectedDisplayType == KeyDisplayType.SimpleLabel) { Assert.Null(keyResult.Modifier); } else { Assert.Equal(expectedSubLabel, keyResult.Modifier.Content); Assert.False(keyResult.Modifier.IsGlyph); } Assert.Equal(expectedCategory, keyResult.KeyCategory); }
public void PrepareEZLayout_InitializeEZKey(string expectedKeyCode, string expectedColor) { // Arrange var ergodoxKey = new ErgodoxKey() { GlowColor = expectedColor, Code = expectedKeyCode }; ErgodoxLayout ergodoxLayout = InitializeDataTree(); ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey); EZLayout ezLayoutResult; // Act var ezLayoutMaker = new EZLayoutMaker(); ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout); // Assert Assert.Single(ezLayoutResult.EZLayers); Assert.Single(ezLayoutResult.EZLayers.First().EZKeys); Assert.Equal(expectedColor, ezLayoutResult.EZLayers.First().EZKeys.First().Color); }
public async Task PostThenDelete() { var chat = this.fixture.GrainFactory.GetGrain <IChatGrain>($"Chatroom-{Guid.NewGuid()}"); var guid = Guid.NewGuid(); await chat.Post(guid, "Famous Athlete", "I am retiring"); { var content = (await chat.GetChat()).ToString(); var doc = XDocument.Load(new StringReader(content)); var container = doc.GetPostsContainer(); Assert.Single(container.Elements("post")); } await chat.Delete(guid); { var content = (await chat.GetChat()).ToString(); var doc = XDocument.Load(new StringReader(content)); var container = doc.GetPostsContainer(); Assert.Empty(container.Elements("post")); } }
public void GetDisksInfoTest_Good() { var res = _good.GetDisksInfo().ToList(); Assert.Equal(5, res.Count); var disk1 = res.Single(c => c.Name.Equals("sda")); Assert.Single(disk1.Partitions); Assert.Equal(1800000, disk1.MemoryInMB); var disk1P1 = disk1.Partitions.Single(c => c.Name == "sda1"); Assert.Equal(1800000, disk1P1.MemoryInMB); Assert.Null(disk1P1.MountingPoint); var disk2 = res.Single(c => c.Name.Equals("mmcblk1")); Assert.Equal(2, disk2.Partitions.Count); Assert.Equal(29000, disk2.MemoryInMB); var disk2P1 = disk2.Partitions.Single(c => c.Name == "mmcblk1p1"); Assert.Equal(128, disk2P1.MemoryInMB); Assert.Null(disk1P1.MountingPoint); var disk2P2 = disk2.Partitions.Single(c => c.Name == "mmcblk1p2"); Assert.Equal(28900, disk2P2.MemoryInMB); Assert.Null(disk2P2.MountingPoint); var disk3 = res.Single(c => c.Name.Equals("mmcblk0")); Assert.Single(disk3.Partitions); Assert.Equal(14700, disk3.MemoryInMB); var disk3P1 = disk3.Partitions.Single(c => c.Name == "mmcblk0p1"); Assert.Equal(14700, disk3P1.MemoryInMB); Assert.Equal("/", disk3P1.MountingPoint); }
public void GetTheDeadCellThatShouldBecomeAliveWhenItHasThreeLiveNeighbours() { var grid = new Grid(5, 5); int[][] graph = { new[] { 0, 0, 1, 1, 0 }, new[] { 0, 1, 0, 0, 0 }, new[] { 0, 0, 0, 0, 0 }, new[] { 0, 0, 0, 0, 0 }, new[] { 0, 0, 0, 0, 0 } }; _testHelper.TransformGraphToCells(graph).ForEach(cell => grid.AddCell(cell)); var allDeadNeighboursOfAliveCells = new List <Cell>(); foreach (var livingCell in grid.LivingCells) { allDeadNeighboursOfAliveCells.AddRange(grid.GetDeadNeighboursOfACell(livingCell)); } int[][] expectedLiveCellsGraph = { new[] { 0, 0, 0, 0, 0 }, new[] { 0, 0, 1, 0, 0 }, new[] { 0, 0, 0, 0, 0 }, new[] { 0, 0, 0, 0, 0 }, new[] { 0, 0, 0, 0, 0 } }; var expectedLiveCells = _testHelper.TransformGraphToCells(expectedLiveCellsGraph); var actualLiveCells = _rules.GetDeadCellsThatShouldLive(allDeadNeighboursOfAliveCells); expectedLiveCells.Should().BeEquivalentTo(actualLiveCells); Assert.Single(actualLiveCells); }
public void PrepareEZLayout_KeyCodeUnknown() { // Arrange var ergodoxKey = new ErgodoxKey() { GlowColor = "", Code = "KC_UNKNOWN_ADSLKFJ" }; ErgodoxLayout ergodoxLayout = InitializeDataTree(); ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey); EZLayout ezLayoutResult; // Act var ezLayoutMaker = new EZLayoutMaker(); ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout); // Assert Assert.Single(ezLayoutResult.EZLayers); Assert.Single(ezLayoutResult.EZLayers.First().EZKeys); Assert.Equal("", ezLayoutResult.EZLayers.First().EZKeys.First().Label.Content); Assert.False(ezLayoutResult.EZLayers.First().EZKeys.First().Label.IsGlyph); }
public void DumpSReturnsCorrectMatrix() { using var sim = new QuantumSimulator(); var diagnostics = new List <object>(); sim.OnDisplayableDiagnostic += diagnostic => { diagnostics.Add(diagnostic); }; sim.DisableLogToConsole(); DumpS.Run(sim).Wait(); Assert.Single(diagnostics); var diagnostic = diagnostics.Single(); Assert.IsType <DisplayableUnitaryOperator>(diagnostic); var unitary = diagnostic as DisplayableUnitaryOperator; Assert.NotNull(unitary); Assert.Equal(1, unitary.Qubits?.Count); Assert.NotNull(unitary.Data); Assert.Equal(3, unitary.Data.ndim); Assert.Equal(2, unitary.Data.shape[0]); Assert.Equal(2, unitary.Data.shape[1]); Assert.Equal(2, unitary.Data.shape[2]); // Check that the matrix is [1 0; 0 𝑖]. Assert.Equal(1.0, (double)unitary.Data[0, 0, 0], precision: 6); Assert.Equal(0.0, (double)unitary.Data[0, 1, 0], precision: 6); Assert.Equal(0.0, (double)unitary.Data[1, 0, 0], precision: 6); Assert.Equal(0.0, (double)unitary.Data[1, 1, 0], precision: 6); Assert.Equal(0.0, (double)unitary.Data[0, 0, 1], precision: 6); Assert.Equal(0.0, (double)unitary.Data[0, 1, 1], precision: 6); Assert.Equal(0.0, (double)unitary.Data[1, 0, 1], precision: 6); Assert.Equal(1.0, (double)unitary.Data[1, 1, 1], precision: 6); }