コード例 #1
0
        public void WhenTypeAttributeIsNotFound_ThenThrows()
        {
            var processor = new ModelElementDirectiveProcessor();

            processor.StartProcessingRun(provider, null, new CompilerErrorCollection());
            Assert.Throws <DirectiveProcessorException>(() => processor.ProcessDirective("ModelElement", new Dictionary <string, string>()));
        }
コード例 #2
0
        public void WhenPropertyNameIsNull_ThenEvaluateFalse()
        {
            var mockEvent = new Mock <IEvent <PropertyChangedEventArgs> >();

            this.condition.Event = mockEvent.Object;

            Assert.Throws <ValidationException>(() => this.condition.Evaluate());
        }
コード例 #3
0
        public void WhenInitializingAndExttensionPathIsNull_ThenThrowsArgumentNullException()
        {
            var content = new Mock <IExtensionContent>();

            content.Setup(c => c.RelativePath).Returns("foo.patterndefinition");
            content.Setup(c => c.Attributes).Returns(new Dictionary <string, string>()
            {
                { "AssemblyFile", "bar.dll" }
            });

            Assert.Throws <ArgumentNullException>(() => new SchemaResource(null, content.Object));
        }
コード例 #4
0
        public void WhenGettingOutputAssembly_ThenCanInspectAssemblyUsingReflection()
        {
            base.OpenSolution("SampleSolution\\SampleSolution.sln");

            var explorer = base.ServiceLocator.GetInstance <ISolutionExplorer>();
            var lib      = explorer.Solution.Traverse().OfType <IProjectNode>()
                           .FirstOrDefault(node => node.DisplayName == "ClassLibrary");

            var asm = lib.GetOutputAssembly().Result;

            var type = asm.GetTypes().First(t => t.GetConstructor(new Type[0]) != null);

            Assert.Throws <ArgumentException>(() => Activator.CreateInstance(type));
        }
コード例 #5
0
 public void WhenConstructedWithNullAction_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         using (new AnonymousDisposable(null))
         {
         }
     });
 }
コード例 #6
0
        public void WhenSourceIsNullWithOnNext_ThenThrowsArgumentNullException()
        {
            IObservable <IEvent <EventArgs> > source = null;

            Assert.Throws <ArgumentNullException>(() =>
                                                  source.Subscribe(e => { }));
        }
コード例 #7
0
        public void WhenValueProviderBindingFails_ThenThrowsInvalidOperationExceptionAndTraces()
        {
            var settings = new PropertyBindingSettings {
                ValueProvider = new ValueProviderBindingSettings {
                }
            };

            Mock.Get(this.binding)
            .Setup(x => x.Evaluate(It.IsAny <IDynamicBindingContext>()))
            .Returns(false);

            Assert.Throws <InvalidOperationException>(() => settings.Evaluate(this.bindingFactory, this.tracer));
            Mock.Get(this.tracer)
            .Verify(x => x.Trace(TraceEventType.Error, It.IsAny <string>(), It.IsAny <object[]>()));
        }
コード例 #8
0
        public void WhenRetrievingExportedValueOrDefaultForMany_ThenThrowsImportCardinalityException()
        {
            var components = GlobalServiceProvider.Instance.GetService <SComponentModel, IComponentModel>();

            // ICompletionSourceProvider has many exports.
            // On VS2010 this throws, but on VS2012+ it succeeds and returns null :S
#if Vs10
            Assert.Throws <ImportCardinalityMismatchException>(() =>
                                                               components.DefaultExportProvider.GetExportedValueOrDefault <ICompletionSourceProvider>());
#endif

#if Vs11 || Vs12
            Assert.Equal <ICompletionSourceProvider>(null, components.DefaultExportProvider.GetExportedValueOrDefault <ICompletionSourceProvider>());
#endif
        }
コード例 #9
0
 public void WhenResolvingNullUri_ThenThrowsException()
 {
     Assert.Throws <ArgumentNullException>(
         () => this.provider.ResolveUri(null));
 }
コード例 #10
0
 public void WhenGettingName_ThenExceptionIsThrown()
 {
     Assert.Throws <InvalidOperationException>(() => this.patternModel.GetUniqueName("Foo"));
 }
コード例 #11
0
 public void WhenCreatingNewWithNullServiceProvider_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => new ProxyServiceProvider(null));
 }
コード例 #12
0
 public void WhenCreatingACloner_ThenNullExceptionIsThrown()
 {
     Assert.Throws <ArgumentNullException>(() => new PatternModelCloner(null, null, null));
 }
コード例 #13
0
 public void WhenCreatingAClonerWithNullTargetPatternModel_ThenNullExceptionIsThrown()
 {
     Assert.Throws <ArgumentNullException>(
         () => new PatternModelCloner(this.sourcePatternModel, new Version("1.0.0.0"), null));
 }
コード例 #14
0
 public void WhenResolveUriWithNullUri_ThenThrows()
 {
     Assert.Throws <NullReferenceException>(() => this.service.ResolveUri <IItemContainer>(null));
 }
コード例 #15
0
 public void WhenGettingNameWithNull_ThenExceptionIsThrown()
 {
     Assert.Throws <ArgumentNullException>(() => this.patternModel.GetUniqueName(null));
 }
コード例 #16
0
 public void WhenInitializingWithANullExtension_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => new InstalledToolkitInfo(this.extension, this.reader, this.resource));
 }
コード例 #17
0
 public void WhenEnumerableIsNull_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => EnumerableExtensions.ForEach <string>(null, s => { }));
 }
コード例 #18
0
 public void WhenCreatingWithNullSender_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => Event.Create <EventArgs>(null, EventArgs.Empty));
 }
コード例 #19
0
 public void WhenFindingWithNullManager_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => PatternManagerExtensions.Find(null, "foo"));
 }
コード例 #20
0
 public void WhenCreatingMenuCommandAndCommandIsNull_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => new VsMenuCommandAdapter(null));
 }
コード例 #21
0
 public void WhenFindToolkitOrThrowWithUnknownTemplate_ThenThrows()
 {
     Assert.Throws <InvalidOperationException>(() =>
                                               InstantiationTemplateWizard.FindToolkitOrThrow(this.manager, @"C:\undefined.vstemplate"));
 }
コード例 #22
0
            public void WhenPatternManagerIsNotOpen_ThenThrowsInvalidOperationException()
            {
                Mock.Get(this.Command.PatternManager).Setup(x => x.IsOpen).Returns(false);

                Assert.Throws <InvalidOperationException>(Resources.GenerateProductCodeCommand_PatternManagerNotOpen, () => Command.Execute());
            }
コード例 #23
0
 public void WhenCreatingWithNullServiceProvider_ThenThrowsException()
 {
     Assert.Throws <ArgumentNullException>(() => new VsTemplateUriProvider(null));
 }
コード例 #24
0
 public void WhenNullAddHandler_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           WeakObservable.FromEvent <EventArgs>(null, handler => { }));
 }
コード例 #25
0
 public void WhenLoadingAModelWithNullStream_ThenNullExceptionIsThrown()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           PatternModelSerializationHelper.Instance.LoadModel(this.store, null, null, null));
 }
コード例 #26
0
 public void WhenGettingOtherContentWithNullContentType_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => this.target.GetCustomExtensions(null));
 }