public static TvDatabase.Channel GetChannel(out ChannelMap channelMap) { channelMap = Isolate.Fake.Instance <ChannelMap>(); List <ChannelMap> channelMaps = new List <ChannelMap>(); channelMaps.Add(channelMap); TvDatabase.Channel channel = Isolate.Fake.Instance <TvDatabase.Channel>(); Isolate.WhenCalled(() => channel.DisplayName).WillReturn("Test Channel"); Isolate.WhenCalled(() => channel.ReferringChannelMap()).WillReturn(channelMaps); return(channel); }
public void CanGetAllPromosFromRepository() { SPSite spSite = new SPSite("http://localhost:9001/sites/pssportal"); Isolate.WhenCalled(() => SPContext.Current.Site).WillReturn(spSite); PartnerPromotionRepository partnerPromotionRepository = new PartnerPromotionRepository(); IList <PartnerPromotionEntity> promoPages = partnerPromotionRepository.GetAllMyPromos(); Assert.AreEqual(3, promoPages.Count); }
public void When_Parameter_Is_A_Chain() { XPMemberInfo collectionMemberInfo = GetCollectionMemberInfo(); Isolate.WhenCalled(() => XpandReflectionHelper.GetXpMemberInfo(null, "Customers")).WithExactArguments().WillReturn(collectionMemberInfo); var parser = new PropertyPathParser(null, Session.DefaultSession); CriteriaOperator criteriaOperator = parser.Parse("Customers", "Order.OrderLine.Ammount=50"); Assert.AreEqual(new ContainsOperator("Customers", new BinaryOperator("Order.OrderLine.Ammount", 50)).ToString(), criteriaOperator.ToString()); }
public void StartTheExplorerWhenInitializingThePlugin() { Sentry pluginSentry = Monitor.Interactions(typeof(PlugIn)); Isolate.WhenCalled(() => VisualStudio.Solution).WillReturn(""); Isolate.WhenCalled(() => VisualStudio.HasASolutionOpened).WillReturn(true); Isolate.WhenCalled(() => VisualStudio.HasAnActiveTextView).WillReturn(true); PlugIn plugin = new PlugIn(); Approvals.Approve(pluginSentry.Report); }
public void SetConfigValueLogs() { SPFarm fakeFarm = Isolate.Fake.Instance <SPFarm>(); Isolate.WhenCalled(() => fakeFarm.Properties).WillReturn(new Hashtable()); var target = new HierarchicalConfig(new MockPropertyBag()); target.SetInPropertyBag("myKey", "myValue", fakeFarm); Assert.AreEqual("Set value in hierarchical config.\n\tKey: 'myKey'\n\tLevel: 'CurrentSPFarm'\n\tValue: 'myValue'", logger.TraceMessage); }
public void return_success_is_true_when_password_change_for_valid_user() { Isolate.WhenCalled(() => LoginServices.ChangePassword(_user, TempPassword)).IgnoreCall(); Isolate.WhenCalled(() => LoginServices.CheckPassword(TempPassword)).WillReturn(true); SetEnvironmentOnController(); var result = _controller.ChangePassword(ValidUser, ValidPassword, TempPassword); Isolate.Verify.WasCalledWithAnyArguments(() => LoginServices.ChangePassword(_user, TempPassword)); Assert.IsTrue(GetSuccessValueFromActionResult(result), "Password was not changed"); }
public void LoadDocTypesTest_IntPropertyMapping() { DocTypeObjectBuilder target = new DocTypeObjectBuilder(string.Empty); var intReader = Isolate.Fake.Instance <IRecordsReader>(); Isolate.WhenCalled(() => intReader.GetDbType()).WillReturn("Integer"); var intProp = target.BuildProperty(intReader); Assert.AreEqual(typeof(int), intProp.DatabaseType); }
public void return_success_is_false_when_invalid_login() { var userName = _user.UserName; Isolate.WhenCalled(() => LoginServices.IsLoggedIn(userName)).WillReturn(false); SetEnvironmentOnController(); var result = _controller.Login(_user); Assert.IsFalse(GetSuccessValueFromActionResult(result)); }
public void LoadDocTypesTest_DbCalled() { ISqlHelper sql = Isolate.Fake.Instance <ISqlHelper>(Members.ReturnRecursiveFakes); DocTypeObjectBuilder target = new DocTypeObjectBuilder(string.Empty); Isolate.WhenCalled(() => target.SqlHelper).WillReturn(sql); target.LoadDocTypes(); Isolate.Verify.WasCalledWithAnyArguments(() => target.SqlHelper); Isolate.Verify.WasCalledWithAnyArguments(() => sql.ExecuteReader(string.Empty)); }
public void When_PropertyPath_Is_A_Collection_Without_Chain() { XPMemberInfo collectionMemberInfo = GetCollectionMemberInfo(); Isolate.WhenCalled(() => XpandReflectionHelper.GetXpMemberInfo(null, "Orders")).WithExactArguments().WillReturn(collectionMemberInfo); var parser = new PropertyPathParser(null, Session.DefaultSession); CriteriaOperator criteriaOperator = parser.Parse("Orders", "Amount=50"); Assert.AreEqual("[Orders][[Amount] = 50]", criteriaOperator.ToString()); }
public void ask_login_services_if_user_is_logged_in() { var name = _user.UserName; Isolate.WhenCalled(() => LoginServices.IsLoggedIn(name)).WillReturn(true); SetEnvironmentOnController(); _controller.Login(_user); Isolate.Verify.WasCalledWithExactArguments(() => LoginServices.IsLoggedIn(name)); }
public void CanGetSpecificPromoFromRepository() { SPSite spSite = new SPSite("http://localhost:9001/sites/pssportal"); Isolate.WhenCalled(() => SPContext.Current.Site).WillReturn(spSite); PartnerPromotionRepository partnerPromotionRepository = new PartnerPromotionRepository(); PartnerPromotionEntity partnerPromotion = partnerPromotionRepository.GetBySku("2000000000"); Assert.AreEqual("2000000000", partnerPromotion.Sku); Assert.AreEqual("PromoDesc", partnerPromotion.Description); }
public void append_a_cookie_to_response_when_successfull_login() { var cookie = Isolate.Fake.Instance <HttpCookie>(); Isolate.WhenCalled(() => LoginServices.IsLoggedIn(ValidUser)).WillReturn(true); Isolate.WhenCalled(() => _controller.Response).WillReturn(_response); SetEnvironmentOnController(); _controller.Login(_user); Isolate.Verify.WasCalledWithAnyArguments(() => _response.AppendCookie(cookie)); }
public void return_success_is_true_when_valid_user_login() { // Setup Isolate.WhenCalled(() => LoginServices.IsLoggedIn(ValidUser)).WillReturn(true); Isolate.WhenCalled(() => LoginServices.GetLoggedIn()).WillReturn(ValidUser); Isolate.WhenCalled(() => _controller.Response).ReturnRecursiveFake(); SetEnvironmentOnController(); var result = _controller.Login(_user); Assert.IsTrue(GetSuccessValueFromActionResult(result)); }
IFrameCreationHandler IViewCreationHandler.CreateDetailView() { foreach (var info in _currentObject.ClassInfo.CollectionProperties.OfType <XPMemberInfo>()) { _applicationNodeWrapper.Load(info.CollectionElementType.ClassType); ((IViewCreationHandler)this).CreateListView(false, null); } _view = new DetailView(_objectSpace, _currentObject, _xafApplication, true); Isolate.WhenCalled(() => _view.SynchronizeWithInfo()).IgnoreCall(); _view.SetInfo(_applicationNodeWrapper.Views.GetDetailViews(typeof(TObject))[0].Node); return(this); }
public void ReturnSuccessIsTrueValueWhenCanDeleteProduct() { IsolateController(); var product = Isolate.Fake.Instance <IProduct>(); Isolate.Fake.StaticMethods(typeof(ProductServices)); Isolate.WhenCalled(() => ProductServices.Delete(product)).IgnoreCall(); var result = _controller.DeleteProduct(Guid.NewGuid().ToString()); Assert.IsTrue(ActionResultParser.GetSuccessValue(result)); }
// public static TypesInfo WCTypesInfo(this IFaker faker) { // Isolate.WhenCalled(() => TypesInfo.Instance).WillReturn(Isolate.Fake.Instance<TypesInfo>()); // var typesInfo = TypesInfo.Instance; // // Isolate.WhenCalled(() => typesInfo.ExtendedCoreMemberInfoType).WillReturn(typeof (ExtendedCoreTypeMemberInfo)); // Isolate.WhenCalled(() => typesInfo.ExtendedCoreMemberInfoType).WillReturn(typeof (ExtendedCoreTypeMemberInfo)); // Isolate.WhenCalled(() => typesInfo.ExtendedReferenceMemberInfoType).WillReturn(typeof (ExtendedReferenceMemberInfo)); // Isolate.WhenCalled(() => typesInfo.ExtendedCollectionMemberInfoType).WillReturn(typeof (ExtendedCollectionMemberInfo)); // Isolate.WhenCalled(() => typesInfo.PersistentAssemblyInfoType).WillReturn(typeof (PersistentAssemblyInfo)); // Isolate.WhenCalled(() => typesInfo.PersistentCoreTypeInfoType).WillReturn(typeof (PersistentCoreTypeMemberInfo)); // Isolate.WhenCalled(() => typesInfo.PersistentClassInfoInfoType).WillReturn(typeof (PersistentClassInfo)); // Isolate.WhenCalled(() => typesInfo.PersistentCollectionInfoType).WillReturn(typeof(PersistentCollectionMemberInfo)); // Isolate.WhenCalled(() => typesInfo.CodeTemplateInfoType).WillReturn(typeof (CodeTemplateInfo)); // Isolate.WhenCalled(() => typesInfo.PersistentReferenceInfoType).WillReturn(typeof (PersistentReferenceMemberInfo)); // Isolate.WhenCalled(() => typesInfo.CodeTemplateType).WillReturn(typeof (CodeTemplate)); // Isolate.WhenCalled(() => typesInfo.TemplateInfoType).WillReturn(typeof (TemplateInfo)); // Isolate.WhenCalled(() => typesInfo.IntefaceInfoType).WillReturn(typeof (InterfaceInfo)); // Isolate.WhenCalled(() => typesInfo.PersistentAssociationAttributeType).WillReturn(typeof (PersistentAssociationAttribute)); // Isolate.WhenCalled(() => typesInfo.PersistentDefaultClassOptionsAttributeType).WillReturn(typeof (PersistentDefaultClassOptionsAttribute)); // // return typesInfo; // } public static TypesInfo IOTypesInfo(this IFaker faker) { Isolate.WhenCalled(() => TypesInfo.Instance).WillReturn(Isolate.Fake.Instance <TypesInfo>()); var typesInfo = TypesInfo.Instance; Isolate.WhenCalled(() => typesInfo.SerializationConfigurationType).WillReturn(typeof(SerializationConfiguration)); Isolate.WhenCalled(() => typesInfo.ClassInfoGraphNodeType).WillReturn(typeof(ClassInfoGraphNode)); return(typesInfo); }
public async Task Test02() { // arrange Isolate.WhenCalled(() => WebApiCalls.GetGoogleHomepageAsync()) .WillReturn(Task.FromResult("fake data")); // act bool result = await WebScraper.GetAndSaveGoogleImageOfTheDay(); // assert Assert.AreEqual(false, result); }
public void When_PropertyPath_Is_A_Reference_Object_With_A_Reference_Object_In_Chain() { XPMemberInfo associationMemberInfo = GetAssociationMemberInfo(); Isolate.WhenCalled(() => XpandReflectionHelper.GetXpMemberInfo(null, "Order")).WillReturn(associationMemberInfo); Isolate.WhenCalled(() => XpandReflectionHelper.GetXpMemberInfo(null, "Order.OrderLine")).WillReturn(associationMemberInfo); var parser = new PropertyPathParser(null, Session.DefaultSession); CriteriaOperator criteriaOperator = parser.Parse("Order.OrderLine", "Amount=50"); Assert.AreEqual(new BinaryOperator("Order.OrderLine.Amount", 50).ToString(), criteriaOperator.ToString()); }
public void not_change_the_password_when_not_logged_in() { Isolate.Fake.StaticMethods(typeof(LoginServices)); Isolate.WhenCalled(() => LoginServices.ChangePassword(_user, "newpassword")).IgnoreCall(); SetEnvironmentOnController(); var result = _controller.ChangePassword("foo", "oldpassword", "newpassword"); Isolate.Verify.WasCalledWithAnyArguments(() => LoginServices.ChangePassword(_user, "newpassword")); Assert.IsFalse(GetSuccessValueFromActionResult(result), "Password was not changed"); }
public void TestDetermineWinner_B_IsTheWinner() { var P1 = Isolate.Fake.Instance <Player>(); var P2 = Isolate.Fake.Instance <Player>(); Isolate.WhenCalled(() => P1.Age).WillReturn(0); Isolate.WhenCalled(() => P2.Age).WillReturn(1); var result = new ClassUnderTest().DetermineWinner(P1, P2); Assert.AreEqual(P2, result); }
public void HideOverlayWhenTextHasChanged() { Sentry pluginSentry = Monitor.Interactions(typeof(PlugIn)); Isolate.WhenCalled(() => VisualStudio.HasASolutionOpened).WillReturn(false); PlugIn plugin = new PlugIn(); plugin.WhenTextChanges(null); Approvals.Approve(pluginSentry.Report); }
protected override void Initialize() { base.Initialize(); _jobSchedulerModule = new JobSchedulerModule(); Isolate.Swap.AllInstances <JobSchedulerModule>().With(_jobSchedulerModule); var properties = SchedulerConfig.GetProperties(); IScheduler scheduler = new XpandSchedulerFactory(properties, Application).GetScheduler(); Isolate.WhenCalled(() => _jobSchedulerModule.Scheduler).WillReturn(scheduler); Scheduler = scheduler; XafTypesInfo.Instance.FindTypeInfo(typeof(DummyJobListener)); }
public void NotAddFoundEntityToRepository() { var factory = new PackageFactory(PackageTestFixtures.GetDtoWithTwoShapes()); var package = Isolate.Fake.Instance <Package>(); var repos = Isolate.Fake.Instance <IRepository <Package> >(); Isolate.NonPublic.WhenCalled(factory, "Find").WillReturn(package); Isolate.WhenCalled(() => repos.Add(package)).IgnoreCall(); factory.Get(); Isolate.Verify.WasNotCalled(() => repos.Add(package)); }
private void TestWrongTuningDetailForCardForFTAChannel(CardType cardType) { Dictionary <int, ITvCardHandler> cards = new Dictionary <int, ITvCardHandler>(); List <IChannel> tuningDetails = new List <IChannel>(); IUser user = Fakes.FakeUser(); TvBusinessLayer businessLayer = Fakes.FakeTvBusinessLayer();; TVController controller = Fakes.FakeTVController(); //we need to pick a different cardtype here- CardType cardTypeDifferent = cardType; switch (cardType) { case CardType.DvbT: cardTypeDifferent = CardType.DvbC; break; case CardType.DvbC: cardTypeDifferent = CardType.DvbS; break; case CardType.DvbS: cardTypeDifferent = CardType.DvbT; break; } IChannel tuningDetail1 = GetFTATuningDetailBasedOnCardType(cardTypeDifferent); tuningDetails.Add(tuningDetail1); DVBCardMocks dvbCardMocks = GetCardMockByCardType(cardType, tuningDetails, user); ITvCardHandler cardHandler1 = dvbCardMocks.GetMockedCardHandler(); //ITvCardHandler cardHandler1 = DVBTCardMocks.AddIdleFTADVBTCard(tuningDetail1, user); cards.Add(dvbCardMocks.CardId, cardHandler1); ChannelMap channelMap; Channel channel = ChannelMocks.GetChannel(out channelMap); Isolate.WhenCalled(() => businessLayer.GetTuningChannelsByDbChannel(channel)).WillReturn(tuningDetails); TVControllerMocks.CardPresent(cardHandler1.DataBaseCard.IdCard, controller); SetupChannelMapping(cardHandler1, channelMap, businessLayer, channel); AdvancedCardAllocation allocation = new AdvancedCardAllocation(businessLayer, controller); TvResult result; List <CardDetail> availCards = allocation.GetFreeCardsForChannel(cards, channel, ref user, out result); Assert.AreEqual(0, availCards.Count, "The number of cards returned is not as expected"); }
public void IsDateFormat_Test_ReturnsFalse() { // arrange var customValidator = new CustomValidator(); Isolate.WhenCalled(() => Regex.IsMatch(null, null)).WillReturn(false); // act var result = customValidator.IsDateFormat("date"); // assert Assert.AreEqual(false, result); }
public void UpdateOverlayWhenPaintingBackground() { Sentry pluginSentry = Monitor.Interactions(typeof(PlugIn)); Isolate.WhenCalled(() => VisualStudio.Solution).WillReturn(""); Isolate.WhenCalled(() => VisualStudio.HasASolutionOpened).WillReturn(true); Isolate.WhenCalled(() => VisualStudio.HasAnActiveTextView).WillReturn(true); PlugIn plugin = new PlugIn(); plugin.WhenPaintingBackground(null); Approvals.Approve(pluginSentry.Report); }
public void CacheResults() { var serviceSentry = Monitor.Interactions(typeof(Service)); Isolate.WhenCalled(() => VisualStudio.ActiveFilePath).WillReturn("foo.cs"); Service service = new Service(); service.GetCoverageResultsForActiveDocument(); service.GetCoverageResultsForActiveDocument(); Approvals.Approve(serviceSentry.Report); }
public void TestMethod_ValidRequest_ShouldTestSuccessfully() { // Arrange var request = new TestMethodRequest(); Isolate.WhenCalled(() => _databaseLayer.Add(null)).WillReturn(1000); // Act var response = _testService.TestMethod(request); // Assert Assert.IsNotNull(response); Assert.AreEqual(1000, response.Id); }
public void PartnerSiteDirectoryConstructorTest() { SharePointServiceLocator.ReplaceCurrentServiceLocator(new ActivatingServiceLocator() .RegisterTypeMapping <IHierarchicalConfig, MockConfigManager>()); SPFarm fakeFarm = Isolate.Fake.Instance <SPFarm>(); Isolate.WhenCalled(() => SPFarm.Local).WillReturn(fakeFarm); PartnerSiteDirectory target = new PartnerSiteDirectory(); Assert.IsNotNull(target); }