public void NotEqualBuildingNamesHaveDifferentHashCode() { // Arrange BuildingBlockName name1 = new BuildingBlockName("Test"); BuildingBlockName name2 = new BuildingBlockName("Test2"); // Assert Assert.AreNotEqual <int>(name1.GetHashCode(), name2.GetHashCode(), "Should not be equal"); }
public void LevelNumberInNameDoesNotMatchRealLevelNumberUsingEqualsOperator() { // Arrange BuildingBlockName name1 = new BuildingBlockName("Test_1"); BuildingBlockName name2 = new BuildingBlockName("Test", 1); // Assert Assert.IsFalse(name1 == name2, "Should not be equal"); }
public void NotEqualsOperatorChecksObjectsForInequality() { // Arrange BuildingBlockName name1 = new BuildingBlockName("Test"); BuildingBlockName name2 = new BuildingBlockName("Test"); // Assert Assert.IsFalse(name1 != name2, "Should be equal"); }
public void EqualBuildingNamesHaveSameHashCode() { // Arrange BuildingBlockName name1 = new BuildingBlockName("Test"); BuildingBlockName name2 = new BuildingBlockName("Test"); // Assert Assert.AreEqual <int>(name1.GetHashCode(), name2.GetHashCode(), "Should be equal"); }
public void EqualsDoesNotMatchTwoDifferentLevelsForSameName() { // Arrange BuildingBlockName name1 = new BuildingBlockName("Test", 1); BuildingBlockName name2 = new BuildingBlockName("Test", 2); // Assert Assert.IsFalse(name1.Equals(name2), "Should not be equal"); }
public void EqualsOperatorMatchesTwoEqualBuildingBlockNamesCaseInsensitively() { // Arrange BuildingBlockName name1 = new BuildingBlockName("Test"); BuildingBlockName name2 = new BuildingBlockName("test"); // Assert Assert.IsTrue(name1 == name2, "Should be equal"); }
public void EqualsDoesNotMatchTwoDifferentNonLevelSpecificNames() { // Arrange BuildingBlockName name1 = new BuildingBlockName("Test"); BuildingBlockName name2 = new BuildingBlockName("Test2"); // Assert Assert.IsFalse(name1.Equals(name2), "Should not be equal"); }
public void EqualsMatchesTwoLevelSpecificNamesCaseInsensitively() { // Arrange BuildingBlockName name1 = new BuildingBlockName("Test", 1); BuildingBlockName name2 = new BuildingBlockName("test", 1); // Assert Assert.IsTrue(name1.Equals(name2), "Should be equal"); }
public void EqualsMatchesTwoNonLevelSpecificNames() { // Arrange BuildingBlockName name1 = new BuildingBlockName("Test"); BuildingBlockName name2 = new BuildingBlockName("Test"); // Assert Assert.IsTrue(name1.Equals(name2), "Should be equal"); }
public void ConstructingNameWithLevelAddsLevelToStringRepresentation() { // Arrange this.sut = new BuildingBlockName("Test", 1); // Act string ans = this.sut.ToString(); // Assert Assert.AreEqual <string>("Test_1", ans); }
public void ConstructingDefaultNameWithLevelReturnsLevelSpecificDefaultStringRepresentation() { // Arrange this.sut = new BuildingBlockName(1); // Act string ans = this.sut.ToString(); // Assert Assert.AreEqual <string>(Constants.DefaultBuildingBlockName + "_1", ans); }
public void PreviewPropertyIsThePreviewBuildingBlockName() { // Arrange this.sut = BuildingBlockName.Preview; // Act string ans = this.sut.ToString(); // Assert Assert.AreEqual <string>(Constants.PreviewBuildingBlockName, ans); }
public void DefaultPropertyIsTheDefaultBuildingBlockName() { // Arrange this.sut = BuildingBlockName.Default; // Act string ans = this.sut.ToString(); // Assert Assert.AreEqual <string>(Constants.DefaultBuildingBlockName, ans); }
public void ConstructingNameWithBuildingBlockParsesLevelSpecificName() { // Arrange Mock <BuildingBlock> mockBb = new Mock <BuildingBlock>(); mockBb.Setup(bb => bb.Name).Returns("Test_1"); // Act this.sut = new BuildingBlockName(mockBb.Object); // Assert Assert.AreEqual <BuildingBlockName>(new BuildingBlockName("Test", 1), this.sut); }
/// <summary> /// Asserts that a layout contains a particular building block. /// </summary> /// <param name="layout">The layout to check.</param> /// <param name="expectedName">The name of the expected building block.</param> private void AssertLayoutContainsBuildingBlock(LayoutInformation layout, BuildingBlockName expectedName) { Assert.IsTrue(layout.BuildingBlockNames.Where(bbn => bbn == expectedName).Count() == 1, "Layout does not contain expected building block: " + expectedName); }
/// <summary> /// Reads information about a building block from a range in the document. /// </summary> /// <remarks> /// This method generates the information from a given range in a document and so does not need to insert the building block to get the information. /// </remarks> /// <param name="name">The name of the building block.</param> /// <param name="startPosition">The start of the range to get the information for.</param> /// <param name="endPosition">The end of the range to get the information for.</param> /// <returns>The information about the building block.</returns> public BuildingBlockInfo ReadBuildingBlockInfo(BuildingBlockName name, int startPosition, int endPosition) { return(this.CreateBuildingBlockInfoFromRange(name, this.document.Range(startPosition, endPosition))); }