public void ShouldConstructWithDefaultValues()
 {
     var stub = new Stub(IsolatedStorageType.Application);
     stub.AutoSave.ShouldBe(true);
     stub.AutoIncrementQuotaBy.ShouldBe(2d);
     stub.StoreAsSerializedString.ShouldBe(false);
 }
Ejemplo n.º 2
0
        void messageSender_SendCompleted(object sender, SendCompletedEventArgs e)
        {
            string incoming = e.Response;
            if (string.IsNullOrEmpty(incoming)) return;

            string payload, hdr;
            hdr = IPCHelper.ParseResponse(incoming, out payload);
            //MessageBox.Show(payload);

            System.Diagnostics.Debug.Assert(hdr.Equals(IPCHelper.MSGHDR_DATA));

            if (hdr.Equals(IPCHelper.MSGHDR_DATA))
            {
                //MessageBox.Show("Inside if condition");

                    try
                    {
                        AlertsDataTransfer alerts = BCheck.Data.AlertsDataTransfer.Deserialize(payload);
                        Application.Current.Resources.Remove("AlertsDataTransferDataSource");
                        Application.Current.Resources.Add ("AlertsDataTransferDataSource", alerts);
                        Stub sdata = new Stub();//using an intermediate Stub to provide design time data
                        sdata.Alerts = alerts;
                        pageMain.DataContext = sdata;
                        pageMain.AlertsDisplayControl.Visibility = Visibility.Visible;  
                    }
                
                    catch (Exception ex)
                    {
#if DEBUG
                        MessageBox.Show(ex.ToString ());
#endif
                    }
                
            }
        }
Ejemplo n.º 3
0
 public void SetUp()
 {
     _stub = new Stub { Int = 10, Str = "Str", Collection = new List<int> { 1, 2, 3 }, Array = new byte[10] };
     _newStub = new Stub { Collection = new List<int> { 11, 12, 13 } };
     _meta = new Meta { Int = 10, Str = "Str", Collection = new List<int> { 1, 2, 3 }, Array = new byte[10] };
     _helper = new EditorHelper();
 }
        public void ShouldReturnSameValueAfterInitialValueIsCreated()
        {
            var stub = new Stub(IsolatedStorageType.Application) { AutoSave = false };
            var child = stub.SiteAddresses;

            child.ShouldNotBe(null);
            stub.SiteAddresses.ShouldBe(child);
        }
Ejemplo n.º 5
0
        static void Main( string[] args )
        {
            IShoutable stub = new Stub( 6010 );

              while( true ) {
            Console.Write( "[Main] > " );
            Console.WriteLine( "[Main] " + stub.Shout( Console.ReadLine() ) );
              }
        }
Ejemplo n.º 6
0
 public Wrapper(Body entity)
 {
     this.body = entity;
     stubs = new Stub[4];
     stubs[0] = new Stub(this, true);  //x
     stubs[1] = new Stub(this, false); //x
     stubs[2] = new Stub(this, true);  //y
     stubs[3] = new Stub(this, false); //y
 }
        public void ShouldStoreReferenceValue()
        {
            var stub = new Stub(IsolatedStorageType.Application) { AutoSave = false };
            stub.SiteAddresses.ShouldBeInstanceOfType<ObservableCollection<Uri>>();

            var child = new ObservableCollection<Uri>();
            stub.SiteAddresses = child;

            stub.SiteAddresses.ShouldBe(child);
        }
        public void Initialize(AcceptCancelDialog control)
        {
            stub = new Stub();

            InitializeDialog(
                control,
                () => DialogViewModel.ContentDialog(SampleTemplates.TextBox, stub, 400, 200));

            ContentViewModel.Show();
        }
        public void ShouldRunAsyncTest_AlternateUsageStyle()
        {
            Action<AsyncTest> onStart = test =>
                        {
                            var stub = new Stub();
                            var eventCount = 0;
                            stub.Done += delegate { eventCount++; };

                            stub.Done += delegate
                                            {
                                                eventCount.ShouldBe(1);
                                                test.Complete();
                                            };
                            stub.Begin();
                        };
            AsyncTest.Start(onStart);
        }
        public void ShouldRunAsyncTest()
        {
            var stub = new Stub();

            var eventCount = 0;
            stub.Done += delegate { eventCount++; };

            AsyncTest.Start(test =>
                                {
                                    stub.Done += delegate
                                                     {
                                                         eventCount.ShouldBe(1);
                                                         test.Complete();
                                                     };
                                    stub.Begin();
                                });
        }
        public void Execute_RunnerCorrectlyConfigured_CallsEachDataMapper()
        {
            //Assign
            var target = new Stub();
            var savingContext = Substitute.For<AbstractTypeSavingContext>();
            var service = Substitute.For<IAbstractService>();
            var args = new ObjectSavingArgs(null, target, savingContext, service);
            var task = new StandardSavingTask();

            var dataContext = Substitute.For<AbstractDataMappingContext>(target);
            service.CreateDataMappingContext(savingContext).Returns(dataContext);

            var property1 = Substitute.For<AbstractPropertyConfiguration>();
            var config1 = Substitute.For<AbstractPropertyConfiguration>();
            var mapper1 = new StubMapper();

            property1.Mapper = mapper1;
            config1.PropertyInfo = typeof (Stub).GetProperty("Property");
            property1.PropertyInfo = config1.PropertyInfo;
            mapper1.Setup(new DataMapperResolverArgs(null, config1));

            var property2 = Substitute.For<AbstractPropertyConfiguration>();
            var config2 = Substitute.For<AbstractPropertyConfiguration>();
            var mapper2 = new StubMapper();

            property2.Mapper = mapper2;
            config2.PropertyInfo = typeof (Stub).GetProperty("Property2");
            property2.PropertyInfo = config2.PropertyInfo;
            mapper2.Setup(new DataMapperResolverArgs(null, config2));

            savingContext.Config = new AttributeConfigurationLoaderFixture.StubTypeConfiguration();
            savingContext.Config.AddProperty(property1);
            savingContext.Config.AddProperty(property2);

            //Act
            task.Execute(args);

            //Assert
            Assert.IsTrue(mapper1.MapCalled);
            Assert.IsTrue(mapper2.MapCalled);
        }
        public void ShouldDetermineIfIsFirstLoad()
        {
            var stub = new Stub(IsolatedStorageType.Application) { AutoSave = false };
            stub.Clear();
            stub.Store.Save();

            stub.IsFirstLoad.ShouldBe(true);
            stub = new Stub(IsolatedStorageType.Application) { AutoSave = false };
            stub.IsFirstLoad.ShouldBe(true);

            stub.Save();
            stub.IsFirstLoad.ShouldBe(false);
        }
 public void TestSetup()
 {
     stub = new Stub();
 }
 public void ShouldStoreId()
 {
     var stub = new Stub(IsolatedStorageType.Application) { AutoSave = false };
     stub.Id.ShouldBe("TestId");
 }
 public void ShouldConstructAsApplicationSettings()
 {
     var stub = new Stub(IsolatedStorageType.Application) { AutoSave = false };
     stub.StoreType.ShouldBe(IsolatedStorageType.Application);
     stub.Store.ShouldBe(IsolatedStorageSettings.ApplicationSettings);
 }
Ejemplo n.º 16
0
            public void Results_In_Expected_Setup_When_Type_Is_Moqable()
            {
                var myStub = new Stub<IList<string>>();
                myStub.SetupGet<IList<string>, int>(list => list.Count).Returns(12);

                Assert.AreEqual<int>(12, myStub.Object.Count);
            }
 public void Global_Output__WriteProperties_IncludeHierarchy(OutputLog control, bool withTitle = true)
 {
     var stub = new Stub { Text = RandomData.LoremIpsum(5) };
     if (withTitle)
     {
         Output.WriteProperties("My Title", stub, includeHierarchy: true);
     }
     else
     {
         Output.WriteProperties(stub, includeHierarchy: true);
     }
 }
        public void ShouldRemoveDuplicateEntires()
        {
            var stub1 = new Stub{Text = "One"};
            var stub2 = new Stub{Text = "Two"};
            var list = new List<Stub> { stub1, stub1, stub2, stub1, stub2 };

            var distinct = list.Distinct((s1, s2) => s1 == s2);
            distinct.Count().ShouldBe(2);
            distinct.First().ShouldBe(stub1);
            distinct.Last().ShouldBe(stub2);
        }
        public void SetField_ClassContainsIdButItemMissing_ThrowsException()
        {
            //Assign
            var item = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldTypeMapper/SetField");
            var targetId = Guid.Parse("{11111111-A3F0-410E-8A6D-07FF3A1E78C3}");
            var mapper = new SitecoreFieldTypeMapper();
            var field = item.Fields[FieldName];

            var config = new SitecoreFieldConfiguration();
            config.PropertyInfo = typeof(StubContaining).GetProperty("PropertyTrue");

            var context = Context.Create(Utilities.CreateStandardResolver());
            context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration"));
            var service = new SitecoreService(Database, context);

            var propertyValue = new Stub();
            propertyValue.Id = targetId;

            var scContext = new SitecoreDataMappingContext(null, item, service);

            using (new ItemEditing(item, true))
            {
                field.Value = string.Empty;
            }

            //Act
            using (new ItemEditing(item, true))
            {
                mapper.SetField(field, propertyValue, config, scContext);
            }

        }
        public void ShouldGetPreviousItem()
        {
            var item1 = new Stub();
            var item2 = new Stub();
            var item3 = new Stub();
            var item4 = new Stub();
            var list = new List<Stub> { item1, item2, item3 };

            // ---

            ((List<Stub>)null).PreviousItem(item1, true).ShouldBe(null);
            list.PreviousItem(null, true).ShouldBe(null);
            list.PreviousItem(item4, true).ShouldBe(null);

            // ---

            list.PreviousItem(item3, false).ShouldBe(item2);
            list.PreviousItem(item2, false).ShouldBe(item1);
            list.PreviousItem(item1, false).ShouldBe(null);

            // ---

            list.PreviousItem(item3, true).ShouldBe(item2);
            list.PreviousItem(item2, true).ShouldBe(item1);
            list.PreviousItem(item1, true).ShouldBe(item3);

            // ---

            list = new List<Stub> { item1 };
            list.PreviousItem(item1, false).ShouldBe(null);
            list.PreviousItem(item1, true).ShouldBe(item1);
        }
        public void ShouldDispose()
        {
            AddStubsToCollection(3);
            manager.Dispose();

            collection[0].IsSelected = true;
            collection[1].IsSelected = true;
            collection[2].IsSelected = true;

            selectionChangedCount.ShouldBe(0);

            var item = new Stub();
            collection.Add(item);
            item.IsSelected = true;
            selectionChangedCount.ShouldBe(0);
        }
        public void ShouldStopReactingToEventsWhenItemIsReplaced()
        {
            AddStubsToCollection(3);
            var item1 = manager.Collection[0];
            var item2 = new Stub();

            manager.Collection[0] = item2;
            item1.IsSelected = true;
            selectionChangedCount.ShouldBe(0);

            // --

            item2.IsSelected = true;
            selectionChangedCount.ShouldBe(1);
        }
Ejemplo n.º 23
0
            public void Causes_Methods_With_Matching_Type_To_Return_That_Default_When_Stub_IS_Moqable()
            {
                var myStub = new Stub<IComparable>();
                myStub.SetReturnsDefault<int>(12);

                Assert.AreEqual<int>(12, myStub.Object.CompareTo(null));
            }
 public void Global_Output__WriteProperties_Specific(OutputLog control)
 {
     var stub = new Stub { Text = RandomData.LoremIpsum(5) };
     Output.WriteProperties("My Title", stub, m => m.ParentProperty, m => m.Text);
 }
Ejemplo n.º 25
0
            public void Does_Not_Throw_Exception_On_Value_Type()
            {
                var myStub = new Stub<int>();

                ExtendedAssert.DoesNotThrow(() => myStub.SetReturnsDefault<string>("asdf"));
            }
 private void PopulateCollection(int count)
 {
     items.RemoveAll();
     for (var i = 0; i < count; i++)
     {
         var item = new Stub {Text = "Item " + (i+1)};
         items.Add(item);
     }
 }
Ejemplo n.º 27
0
		public void ClosesIfProtectedCodeSucceedsInHalfOpenState()
		{
			var stub = new Stub(10);
			var circuitBreaker = new CircuitBreaker(10, TimeSpan.FromMilliseconds(50));

			CallXAmountOfTimes(() =>
			{
				try
				{
					circuitBreaker.AttemptCall(stub.DoStuff);
				}
				catch
				{
					// Do nothing.
				}
			}, 10);
			
			Thread.Sleep(100);
			circuitBreaker.AttemptCall(stub.DoStuff);
			Assert.True(circuitBreaker.IsClosed);
		}
 public void ShouldAutoSaveByDeafult()
 {
     var stub = new Stub(IsolatedStorageType.Application);
     stub.AutoSave.ShouldBe(true);
 }
 public void TestSetup()
 {
     controller = new Stub();
 }
Ejemplo n.º 30
0
		public void FailuresIsResetWhenCircuitBreakerCloses()
		{
			var stub = new Stub(10);
			var circuitBreaker = new CircuitBreaker(10, TimeSpan.FromMilliseconds(50));

			CallXAmountOfTimes(() =>
			{
				try
				{
					circuitBreaker.AttemptCall(stub.DoStuff);
				}
				catch
				{
					// Do nothing.
				}
			}, 10);
			
			Assert.Equal(10, circuitBreaker.Failures);
			Thread.Sleep(100);
			circuitBreaker.AttemptCall(stub.DoStuff);
			Assert.Equal(0, circuitBreaker.Failures);
		}