public void Create_PackageReference() { var reference = Mock.Of <ISetupPackageReference>(x => x.GetId() == "a"); var actual = PackageReferenceFactory.Create(reference); Assert.IsType <PackageReference>(actual); }
public void GetAdaptedProperties_Empty() { var references = new ISetupPackageReference[0]; Func <ISetupPackageReference, PackageReference> creator = reference => PackageReferenceFactory.Create(reference); var packages = Utilities.GetAdaptedPackages(() => references, creator).ToList(); Assert.Empty(packages); }
public void TrySetCollection_Empty() { IList <PackageReference> property = null; var references = new ISetupPackageReference[0]; Func <ISetupPackageReference, PackageReference> creator = reference => PackageReferenceFactory.Create(reference); var packages = Utilities.TrySetCollection(ref property, nameof(property), () => references, creator); Assert.Empty(packages); }
public void Create_FailedPackageReference() { var reference = new Mock <ISetupFailedPackageReference>(); reference.As <ISetupPackageReference>().Setup(x => x.GetId()).Returns("a"); var actual = PackageReferenceFactory.Create(reference.Object); Assert.IsType <FailedPackageReference>(actual); }
public void GetAdaptedProperties() { var references = new[] { Mock.Of <ISetupPackageReference>(x => x.GetId() == "a"), Mock.Of <ISetupPackageReference>(x => x.GetId() == "b"), }; Func <ISetupPackageReference, PackageReference> creator = reference => PackageReferenceFactory.Create(reference); var packages = Utilities.GetAdaptedPackages(() => references, creator).ToList(); Assert.Collection( packages, x => Assert.Equal("a", x.Id), x => Assert.Equal("b", x.Id)); }
public void TrySetCollection() { IList <PackageReference> property = null; var references = new[] { Mock.Of <ISetupPackageReference>(x => x.GetId() == "a"), Mock.Of <ISetupPackageReference>(x => x.GetId() == "b"), }; Func <ISetupPackageReference, PackageReference> creator = reference => PackageReferenceFactory.Create(reference); var packages = Utilities.TrySetCollection(ref property, nameof(property), () => references, creator); Assert.Collection( packages, x => Assert.Equal("a", x.Id), x => Assert.Equal("b", x.Id)); }
public void TrySetCollection_Error_Callback() { IList <PackageReference> property = null; var called = false; var references = new[] { Mock.Of <ISetupPackageReference>(x => x.GetId() == "a"), Mock.Of <ISetupPackageReference>(x => x.GetId() == "b"), }; Func <ISetupPackageReference, PackageReference> creator = reference => PackageReferenceFactory.Create(reference); var packages = Utilities.TrySetCollection( ref property, nameof(property), () => { throw new COMException("Not found", NativeMethods.E_NOTFOUND); }, creator, propertyName => called = true); Assert.Null(property); Assert.Empty(packages); Assert.True(called); }
public void Create_FailedPackageReference_Null_Throws() { Assert.Throws <ArgumentNullException>("package", () => PackageReferenceFactory.Create((ISetupFailedPackageReference)null)); }