//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldContinueAfterError() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldContinueAfterError()
        {
            DiagnosticsReporter reporter   = new DiagnosticsReporter();
            MyProvider          myProvider = new MyProvider(_fileSystem);

            reporter.RegisterOfflineProvider(myProvider);

            myProvider.AddFile("logs/a.txt", CreateNewFileWithContent("a.txt", "file a"));

            Path          destination = _testDirectory.file("logs.zip").toPath();
            ISet <string> classifiers = new HashSet <string>();

            classifiers.Add("logs");
            classifiers.Add("fail");
            using (MemoryStream baos = new MemoryStream())
            {
                PrintStream            @out     = new PrintStream(baos);
                NonInteractiveProgress progress = new NonInteractiveProgress(@out, false);

                reporter.Dump(classifiers, destination, progress, true);

                assertThat(baos.ToString(), @is(string.Format("1/2 fail.txt%n" + "....................  20%%%n" + "..........%n" + "Error: Step failed%n" + "2/2 logs/a.txt%n" + "....................  20%%%n" + "....................  40%%%n" + "....................  60%%%n" + "....................  80%%%n" + ".................... 100%%%n%n")));
            }

            // Verify content
            URI uri = URI.create("jar:file:" + destination.toAbsolutePath().toUri().RawPath);

            using (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap()))
            {
                IList <string> fileA = Files.readAllLines(fs.getPath("logs/a.txt"));
                assertEquals(1, fileA.Count);
                assertEquals("file a", fileA[0]);
            }
        }
Exemple #2
0
 protected void Panel_Callback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
 {
     string[] data = e.Parameter.Split('|');
     if (data.Length == 3 && data[0] == "drag")
     {
         MyProvider.MoveNode(data[1], data[2]);
         BindTrees();
     }
 }
        private static void Qbserver_ReentrancyDuringInitialization_Impl(Func <IAsyncReactiveQbserver <int>, Task> action, Func <MyObserver <int>, TaskCompletionSource <object> > complete, Action <MyObserver <int> > assert)
        {
            var provider = new MyProvider();
            var observer = provider.CreateQbserver <int>(Expression.Default(typeof(IAsyncReactiveQbserver <int>)));

            var opAsync = action(observer);

            provider.Acquire.WaitOne();

            AssertEx.ThrowsException <AggregateException>(
                () =>
            {
                observer.OnNextAsync(43, CancellationToken.None).Wait();
            },
                ex =>
            {
                var ioe = ex.InnerException as InvalidOperationException;
                Assert.IsNotNull(ioe);
                Assert.IsTrue(ioe.Message.Contains("Concurrent calls"));
            });

            AssertEx.ThrowsException <AggregateException>(
                () =>
            {
                observer.OnErrorAsync(new Exception(), CancellationToken.None).Wait();
            },
                ex =>
            {
                var ioe = ex.InnerException as InvalidOperationException;
                Assert.IsNotNull(ioe);
                Assert.IsTrue(ioe.Message.Contains("Concurrent calls"));
            });

            AssertEx.ThrowsException <AggregateException>(
                () =>
            {
                observer.OnCompletedAsync(CancellationToken.None).Wait();
            },
                ex =>
            {
                var ioe = ex.InnerException as InvalidOperationException;
                Assert.IsNotNull(ioe);
                Assert.IsTrue(ioe.Message.Contains("Concurrent calls"));
            });

            var iv = new MyObserver <int>();

            var tcs = provider.GetObserverAsyncCoreTask;

            tcs.SetResult(iv);

            complete(iv).SetResult(null);
            opAsync.Wait();

            assert(iv);
        }
Exemple #4
0
        public void When_IWeakReferenceProvider()
        {
            var target = new MyProvider();

            var mr1 = WeakReferencePool.RentWeakReference(this, target);

            Assert.AreEqual(target, mr1.GetUnsafeTargetHandle().Target);
            Assert.ReferenceEquals(target.WeakReference.GetUnsafeTargetHandle(), mr1.GetUnsafeTargetHandle());
            Assert.AreEqual(target, mr1.Owner);
        }
Exemple #5
0
        public void GetTotalPrice_EmptyList_ReturnSumOfZero()
        {
            List <Deal> deals = new List <Deal>();

            MyProvider provider = new MyProvider();

            var result = provider.GetTotalPrice(deals, "normalPrice");

            Assert.AreEqual(result, 0);
        }
        public void PropertyValuesInitialized()
        {
            SettingsPropertyCollection props = new SettingsPropertyCollection();
            SettingsProviderCollection provs = new SettingsProviderCollection();

            MyProvider p = new MyProvider();
            MySettings s = new MySettings();
            int        i;

            try
            {
                i = s.Foo;
                Assert.Fail("#1-2");
            }
            catch (SettingsPropertyNotFoundException)
            {
            }

            s.Initialize(new SettingsContext(), props, provs);
            Assert.AreEqual(0, s.PropertyValues.Count, "#2-1");
            Assert.AreEqual(0, s.Context.Count, "#2-2");

            props.Add(new SettingsProperty("Foo", typeof(int), p, false, 10, SettingsSerializeAs.String, null, true, true));
            // initialize w/o the provider
            s.Initialize(new SettingsContext(), props, provs);
            Assert.AreEqual(0, s.PropertyValues.Count, "#3-0");
            Assert.AreEqual(100, s.Foo, "#3-1");
            // ... !!!
            Assert.AreEqual(1, s.PropertyValues.Count, "#3-2");
            SettingsPropertyValue v = s.PropertyValues ["Foo"];

            Assert.AreEqual(100, v.PropertyValue, "#3-3");
            Assert.AreEqual(0, s.Context.Count, "#3-4");

            // initialize w/ the provider
            provs.Add(p);
            provs.Add(new MyProvider2("Bar", 25));
            props.Add(new SettingsProperty("Bar", typeof(int), provs ["MyProvider2"], false, 10, SettingsSerializeAs.String, null, true, true));
            s.Initialize(new SettingsContext(), props, provs);
            Assert.AreEqual(1, s.PropertyValues.Count, "#4-1");
            Assert.AreEqual(100, s.Foo, "#4-2");
            Assert.AreEqual(25, s.Bar, "#4-3");
            // ... !!!
            Assert.AreEqual(2, s.PropertyValues.Count, "#4-3-2");
            Assert.AreEqual(0, s.Context.Count, "#4-4");

            // wrong provider
            props.Remove("Bar");
            props.Add(new SettingsProperty("Bar", typeof(int), provs ["MyProvider"], false, 10, SettingsSerializeAs.String, null, true, true));
            s = new MySettings();
            s.Initialize(new SettingsContext(), props, provs);
            Assert.AreEqual(0, s.PropertyValues.Count, "#5-1");
            Assert.AreEqual(100, s.Foo, "#5-2");
            Assert.AreEqual(10, s.Bar, "#5-3");
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private DiagnosticsReporter setupDiagnosticsReporter() throws java.io.IOException
        private DiagnosticsReporter SetupDiagnosticsReporter()
        {
            DiagnosticsReporter reporter   = new DiagnosticsReporter();
            MyProvider          myProvider = new MyProvider(_fileSystem);

            reporter.RegisterOfflineProvider(myProvider);

            myProvider.AddFile("logs/a.txt", CreateNewFileWithContent("a.txt", "file a"));
            myProvider.AddFile("logs/b.txt", CreateNewFileWithContent("b.txt", "file b"));
            return(reporter);
        }
Exemple #8
0
        public void When_Set_Parent_As_WeakReferenceProvider()
        {
            var child  = new MyObject(12);
            var parent = new MyProvider();

            var store = new DependencyObjectStore(child, MyObject.DataContextProperty, MyObject.TemplatedParentProperty);

            store.Parent = parent;
            Assert.AreEqual(parent, store.Parent);

            store.Parent = null;
            Assert.AreEqual(null, store.Parent);
        }
        public void WithMobileAppControllerConfigProvider_CanBeOverridden()
        {
            var config = new HttpConfiguration();
            var myProvider = new MyProvider();
            new MobileAppConfiguration()
                .WithMobileAppControllerConfigProvider(myProvider)
                .ApplyTo(config);

            var provider = config.GetMobileAppControllerConfigProvider();
            Assert.NotNull(provider);
            Assert.Same(myProvider, provider);
            Assert.IsType<MyProvider>(provider);
        }
        public void ReadAndWriteXmlWorksAsExpected()
        {
            // --- Arrange
            var setting = new MyProvider("name", 12345);

            // --- Act
            var element    = setting.WriteToXml("Settings");
            var newSetting = new MyProvider(element);

            // -- Assert
            setting.Name.ShouldEqual(newSetting.Name);
            setting.Value.ShouldEqual(newSetting.Value);
            setting.GetResourceConnectionFromSettings().ShouldEqual(newSetting.Value.ToString(CultureInfo.InvariantCulture));
        }
Exemple #11
0
        public void AddPropertyNoProviderButInProviders()
        {
            SettingsPropertyCollection props = new SettingsPropertyCollection();
            SettingsProviderCollection provs = new SettingsProviderCollection();

            MyProvider p = new MyProvider();
            MySettings s = new MySettings();

            props.Add(new SettingsProperty("Foo", typeof(string), null, false, 10, SettingsSerializeAs.String, null, true, true));
            provs.Add(p);

            s.Initialize(new SettingsContext(), props, provs);
            Assert.AreEqual(100, s.Foo);
        }
Exemple #12
0
        public void AddPropertyTypeMismatch()
        {
            SettingsPropertyCollection props = new SettingsPropertyCollection();
            SettingsProviderCollection provs = new SettingsProviderCollection();

            MyProvider p = new MyProvider();
            MySettings s = new MySettings();

            props.Add(new SettingsProperty("Foo", typeof(string), p, false, 10, SettingsSerializeAs.String, null, true, true));
            provs.Add(p);

            s.Initialize(new SettingsContext(), props, provs);
            int i = s.Foo;             // it still works as int, regardless of the settings property type...
        }
Exemple #13
0
        public void PropertyValuesInstance()
        {
            SettingsPropertyCollection props = new SettingsPropertyCollection();
            SettingsProviderCollection provs = new SettingsProviderCollection();

            MyProvider p = new MyProvider();
            MySettings s = new MySettings();

            props.Add(new SettingsProperty("Foo", typeof(string), p, false, 10, SettingsSerializeAs.String, null, true, true));
            provs.Add(p);

            s.Initialize(new SettingsContext(), props, provs);
            Assert.AreEqual(s.PropertyValues, s.PropertyValues);
        }
        public void WithMobileAppControllerConfigProvider_CanBeOverridden()
        {
            var config     = new HttpConfiguration();
            var myProvider = new MyProvider();

            new MobileAppConfiguration()
            .WithMobileAppControllerConfigProvider(myProvider)
            .ApplyTo(config);

            var provider = config.GetMobileAppControllerConfigProvider();

            Assert.NotNull(provider);
            Assert.Same(myProvider, provider);
            Assert.IsType <MyProvider>(provider);
        }
Exemple #15
0
        public void When_WeakReferenceProvider_Reused()
        {
            var o1 = new Object();

            var mr1 = WeakReferencePool.RentWeakReference(this, o1);

            WeakReferencePool.ReturnWeakReference(this, mr1);

            var target = new MyProvider();

            Assert.AreEqual(target, target.WeakReference.Target);

            var mr2 = WeakReferencePool.RentWeakReference(target, o1);

            WeakReferencePool.ReturnWeakReference(target, mr2);

            Assert.AreEqual(target, target.WeakReference.Target);
        }
        public HomeControllerTest()
        {
            // Auto Mapper Configurations
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            mapper = mappingConfig.CreateMapper();

            _mockRepo = new Mock <IGenericEfRepository <Student> >();

            IMyProvider provider = new MyProvider(_mockRepo.Object, mapper);

            _controller = new HomeController(provider);

            _mockRepo.Setup(m => m.Get())
            .Returns(Task.FromResult(MockData.Current.Students.AsEnumerable()));
        }
Exemple #17
0
        public void Qbserver_RegularFlow()
        {
            var provider = new MyProvider();
            var observer = provider.CreateQbserver <int>(Expression.Default(typeof(IAsyncReactiveQbserver <int>)));

            var iv = new MyObserver <int>();

            provider.GetObserverAsyncCoreTask.SetResult(iv);

            iv.OnNextTask.SetResult(null);
            observer.OnNextAsync(42, CancellationToken.None).Wait();
            observer.OnNextAsync(43, CancellationToken.None).Wait();
            observer.OnNextAsync(44, CancellationToken.None).Wait();

            iv.OnCompletedTask.SetResult(null);
            observer.OnCompletedAsync(CancellationToken.None).Wait();

            Assert.IsTrue(iv.OnNextLog.SequenceEqual(new[] { 42, 43, 44 }));
            Assert.IsTrue(iv.OnCompletedLog);
        }
Exemple #18
0
        public void FindStore_NonExistingID_ReturnDefaultStore()
        {
            MyProvider provider = new MyProvider();

            provider.stores = new List <Store>()
            {
                new Store {
                    id = 1, isActive = true, name = "Steam"
                },
                new Store {
                    id = 2, isActive = true, name = "GOG"
                },
                new Store {
                    id = 3, isActive = true, name = "Origin"
                }
            };

            var result = provider.FindStore(4);

            Assert.AreEqual("Store not found", result.name);
        }
Exemple #19
0
        public void GetTotalPrice_PopulatedlistNonFloatProperty_ReturnSumOfZero()
        {
            List <Deal> deals = new List <Deal>()
            {
                new Deal {
                    id = "1"
                },
                new Deal {
                    id = "2"
                },
                new Deal {
                    id = "3"
                }
            };

            MyProvider provider = new MyProvider();

            var result = provider.GetTotalPrice(deals, "id");

            Assert.AreEqual(result, 0);
        }
Exemple #20
0
        public void GetTotalPrice_PopulatedListNormalPrice_ReturnTotalNormalPrice()
        {
            List <Deal> deals = new List <Deal>()
            {
                new Deal {
                    normalPrice = 10
                },
                new Deal {
                    normalPrice = 10
                },
                new Deal {
                    normalPrice = 10
                }
            };

            MyProvider provider = new MyProvider();

            var totalNormalPrice = 30;

            var result = provider.GetTotalPrice(deals, "normalPrice");

            Assert.AreEqual(result, totalNormalPrice);
        }
Exemple #21
0
        public void Test1()
        {
            var provider = new MyProvider();

            Assert.Equal("Hello from MyProvider", provider.Greet());
        }
 public MyQuerayble(IQuerable <T> toWrap, Expression expression)
 {
     Equipment  = equipment;
     Provider   = new MyProvider <T>(toWrap);
     Expression = expression;
 }
Exemple #23
0
 public static void Appinitialize()
 {
     MyProvider fileProvider = new MyProvider();
     System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(fileProvider);
 }
		public void PropertyValuesInstance ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider p = new MyProvider ();
			MySettings s = new MySettings ();

			props.Add (new SettingsProperty ("Foo", typeof (string), p, false, 10, SettingsSerializeAs.String, null, true, true));
			provs.Add (p);

			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (s.PropertyValues, s.PropertyValues);
		}
 public ActionResult UpdateTreeListContainer(string sourceKey, string newParentKey)
 {
     MyProvider.MoveNode(sourceKey, newParentKey);
     return(PartialView("TreeListContainerPartial"));
 }
		public void AddPropertyNoProviderButInProviders ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider p = new MyProvider ();
			MySettings s = new MySettings ();

			props.Add (new SettingsProperty ("Foo", typeof (string), null, false, 10, SettingsSerializeAs.String, null, true, true));
			provs.Add (p);

			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (100, s.Foo);
		}
		public void AddPropertyTypeMismatch ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider p = new MyProvider ();
			MySettings s = new MySettings ();

			props.Add (new SettingsProperty ("Foo", typeof (string), p, false, 10, SettingsSerializeAs.String, null, true, true));
			provs.Add (p);

			s.Initialize (new SettingsContext (), props, provs);
			int i = s.Foo; // it still works as int, regardless of the settings property type...
		}
 internal Settings(MyProvider provider)
 {
     _provider = provider;
     LoadFromConfig();
 }
Exemple #29
0
 void BindTrees()
 {
     MyProvider.Bind(LeftTree, "/node/node[@key='1']");
     MyProvider.Bind(RightTree, "/node/node[@key='8']");
 }
 public MyQueryable(IQueryable <T> toWrap, Expression expression)
 {
     Wrapped    = toWrap;
     Provider   = new MyProvider <T>(toWrap);
     Expression = expression;
 }
		public void PropertyValuesInitialized ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider p = new MyProvider ();
			MySettings s = new MySettings ();
			int i;

			try {
				i = s.Foo;
				Assert.Fail ("#1-2");
			} catch (SettingsPropertyNotFoundException) {
			}

			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.PropertyValues.Count, "#2-1");
			Assert.AreEqual (0, s.Context.Count, "#2-2");

			props.Add (new SettingsProperty ("Foo", typeof (int), p, false, 10, SettingsSerializeAs.String, null, true, true));
			// initialize w/o the provider
			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.PropertyValues.Count, "#3-0");
			Assert.AreEqual (100, s.Foo, "#3-1");
			// ... !!!
			Assert.AreEqual (1, s.PropertyValues.Count, "#3-2");
			SettingsPropertyValue v = s.PropertyValues ["Foo"];
			Assert.AreEqual (100, v.PropertyValue, "#3-3");
			Assert.AreEqual (0, s.Context.Count, "#3-4");

			// initialize w/ the provider
			provs.Add (p);
			provs.Add (new MyProvider2 ("Bar", 25));
			props.Add (new SettingsProperty ("Bar", typeof (int), provs ["MyProvider2"], false, 10, SettingsSerializeAs.String, null, true, true));
			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (1, s.PropertyValues.Count, "#4-1");
			Assert.AreEqual (100, s.Foo, "#4-2");
			Assert.AreEqual (25, s.Bar, "#4-3");
			// ... !!!
			Assert.AreEqual (2, s.PropertyValues.Count, "#4-3-2");
			Assert.AreEqual (0, s.Context.Count, "#4-4");

			// wrong provider
			props.Remove ("Bar");
			props.Add (new SettingsProperty ("Bar", typeof (int), provs ["MyProvider"], false, 10, SettingsSerializeAs.String, null, true, true));
			s = new MySettings ();
			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.PropertyValues.Count, "#5-1");
			Assert.AreEqual (100, s.Foo, "#5-2");
			Assert.AreEqual (10, s.Bar, "#5-3");
		}
 internal Settings(MyProvider provider)
 {
     _provider = provider;     // assignment directly to backing field
     LoadFromConfig();
 }