コード例 #1
0
        public void Create_PackageReference()
        {
            var reference = Mock.Of <ISetupPackageReference>(x => x.GetId() == "a");
            var actual    = PackageReferenceFactory.Create(reference);

            Assert.IsType <PackageReference>(actual);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 public void Create_FailedPackageReference_Null_Throws()
 {
     Assert.Throws <ArgumentNullException>("package", () => PackageReferenceFactory.Create((ISetupFailedPackageReference)null));
 }