Skip to content

Commit

Permalink
down to 34 failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Oct 5, 2016
1 parent 012e8a0 commit 5ab9a74
Show file tree
Hide file tree
Showing 27 changed files with 56 additions and 29 deletions.
5 changes: 5 additions & 0 deletions RetailCoder.VBE/Rubberduck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LibGit2Sharp.0.22.0-pre20150516171636\lib\net40\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Vbe.Interop.Forms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>..\libs\Microsoft.Vbe.Interop.Forms.dll</HintPath>
</Reference>
<Reference Include="Ninject.Extensions.Conventions">
<HintPath>..\packages\ninject.extensions.conventions.3.2.0.0\lib\net45-full\Ninject.Extensions.Conventions.dll</HintPath>
</Reference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ public override void Release()
public override bool Equals(SafeComWrapper<Microsoft.Office.Core.CommandBar> other)
{
return IsEqualIfNull(other) ||
((int)other.ComObject.Type == (int)Type
(other != null
&& (int)other.ComObject.Type == (int)Type
&& other.ComObject.Id == Id
&& other.ComObject.Index == Index
&& other.ComObject.BuiltIn == IsBuiltIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public override void Release()
public override bool Equals(SafeComWrapper<Microsoft.Office.Core.CommandBarControl> other)
{
return IsEqualIfNull(other) ||
((int)other.ComObject.Type == (int)Type
(other != null
&& (int)other.ComObject.Type == (int)Type
&& other.ComObject.Id == Id
&& other.ComObject.Index == Index
&& other.ComObject.BuiltIn == IsBuiltIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Office.Core.CommandBarControls> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(CommandBarControls other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Office.Core.CommandBars> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(CommandBars other)
Expand Down
15 changes: 15 additions & 0 deletions Rubberduck.VBEEditor/DisposableWrappers/SafeComWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Access;

namespace Rubberduck.VBEditor.DisposableWrappers
{
Expand Down Expand Up @@ -66,6 +67,20 @@ public override bool Equals(object obj)
public abstract bool Equals(SafeComWrapper<T> other);
public abstract override int GetHashCode();

public static bool operator ==(SafeComWrapper<T> a, SafeComWrapper<T> b)
{
if (ReferenceEquals(a, null) && ReferenceEquals(b, null))
{
return true;
}
return !ReferenceEquals(a, null) && a.Equals(b);
}

public static bool operator !=(SafeComWrapper<T> a, SafeComWrapper<T> b)
{
return !(a == b);
}

[SuppressMessage("ReSharper", "RedundantCast")]
[SuppressMessage("ReSharper", "ForCanBeConvertedToForeach")]
[SuppressMessage("ReSharper", "LoopCanBeConvertedToQuery")]
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/AddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.AddIn> other)
{
return IsEqualIfNull(other) || (other.ComObject.ProgId == ProgId && other.ComObject.Guid == Guid);
return IsEqualIfNull(other) || (other != null && other.ComObject.ProgId == ProgId && other.ComObject.Guid == Guid);
}

public bool Equals(AddIn other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/AddIns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.Addins> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject.Parent, Parent);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject.Parent, Parent));
}

public bool Equals(AddIns other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.Application> other)
{
return IsEqualIfNull(other) || other.ComObject.Version == Version;
return IsEqualIfNull(other) || (other != null && other.ComObject.Version == Version);
}

public bool Equals(Application other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/CodeModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.CodeModule> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(CodeModule other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/CodePane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.CodePane> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(CodePane other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/CodePanes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.CodePanes> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(CodePane other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.Forms.Control> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(Control other)
Expand Down
4 changes: 2 additions & 2 deletions Rubberduck.VBEEditor/DisposableWrappers/VBA/Controls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public int Count

public Control Item(object index)
{
return new Control(InvokeResult(() => (Microsoft.Vbe.Interop.Forms.Control)ComObject.Item(index)));
return new Control(InvokeResult(() => (Microsoft.Vbe.Interop.Forms.ControlClass)ComObject.Item(index)));
}

IEnumerator<Control> IEnumerable<Control>.GetEnumerator()
Expand All @@ -46,7 +46,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.Forms.Controls> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(Controls other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.LinkedWindows> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(LinkedWindows other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.Properties> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(Properties other)
Expand Down
6 changes: 4 additions & 2 deletions Rubberduck.VBEEditor/DisposableWrappers/VBA/Property.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;

namespace Rubberduck.VBEditor.DisposableWrappers.VBA
{
[SuppressMessage("ReSharper", "UseIndexedProperty")]
public class Property : SafeComWrapper<Microsoft.Vbe.Interop.Property>, IEquatable<Property>
{
public Property(Microsoft.Vbe.Interop.Property comObject)
Expand Down Expand Up @@ -78,8 +80,8 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.Property> other)
{
return IsEqualIfNull(other) ||
(other.ComObject.Name == Name && ReferenceEquals(other.ComObject.Parent, ComObject.Parent));
return IsEqualIfNull(other) ||
(other != null && other.ComObject.Name == Name && ReferenceEquals(other.ComObject.Parent, ComObject.Parent));
}

public bool Equals(Property other)
Expand Down
3 changes: 2 additions & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/Reference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public override void Release()
public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.Reference> other)
{
return IsEqualIfNull(other) ||
((int)other.ComObject.Type == (int)Type
(other != null
&& (int)other.ComObject.Type == (int)Type
&& other.ComObject.Name == Name
&& other.ComObject.Guid == Guid
&& other.ComObject.FullPath == FullPath
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/References.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.References> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject.Parent, Parent.ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject.Parent, Parent.ComObject));
}

public bool Equals(References other)
Expand Down
3 changes: 1 addition & 2 deletions Rubberduck.VBEEditor/DisposableWrappers/VBA/VBComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public string Name
set { Invoke(() => ComObject.Name = value); }
}

// ReSharper disable once ReturnTypeCanBeEnumerable.Global
public Controls Controls
{
get
Expand Down Expand Up @@ -111,7 +110,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.VBComponent> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(VBComponent other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.VBComponents> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(VBComponents other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/VBE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.VBE> other)
{
return IsEqualIfNull(other) || other.ComObject.Version == Version;
return IsEqualIfNull(other) || (other != null && other.ComObject.Version == Version);
}

public bool Equals(VBE other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/VBProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.VBProject> other)
{
return IsEqualIfNull(other) || other.ComObject == ComObject;
return IsEqualIfNull(other) || (other != null && other.ComObject == ComObject);
}

public bool Equals(VBProject other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/VBProjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.VBProjects> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(VBProjects other)
Expand Down
5 changes: 4 additions & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.Window> other)
{
return IsEqualIfNull(other) || ((int)other.ComObject.Type == (int)Type && other.ComObject.HWnd == HWnd);
return IsEqualIfNull(other) || (
other != null
&& (int)other.ComObject.Type == (int)Type
&& other.ComObject.HWnd == HWnd);
}

public bool Equals(Window other)
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void Release()

public override bool Equals(SafeComWrapper<Microsoft.Vbe.Interop.Windows> other)
{
return IsEqualIfNull(other) || ReferenceEquals(other.ComObject, ComObject);
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.ComObject, ComObject));
}

public bool Equals(Windows other)
Expand Down
4 changes: 2 additions & 2 deletions RubberduckTests/Refactoring/ExtractInterfaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void ExtractInterfaceRefactoring_NullPresenter_NoChanges()
refactoring.Refactor();

//Assert
Assert.AreEqual(1, project.VBComponents.Cast<VBComponent>().Count()); // somehow, the VBComponents Count mock isn't working
Assert.AreEqual(1, project.VBComponents.Count());
Assert.AreEqual(inputCode, project.VBComponents.Item(0).CodeModule.Lines());
}

Expand Down Expand Up @@ -399,7 +399,7 @@ public void ExtractInterfaceRefactoring_NullModel_NoChanges()
refactoring.Refactor();

//Assert
Assert.AreEqual(1, project.VBComponents.Cast<VBComponent>().Count()); // somehow, the VBComponents Count mock isn't working
Assert.AreEqual(1, project.VBComponents.Count());
Assert.AreEqual(inputCode, project.VBComponents.Item(0).CodeModule.Lines());
}

Expand Down

0 comments on commit 5ab9a74

Please sign in to comment.