当前位置: 首页>>代码示例>>C#>>正文


C# Story.AsA方法代码示例

本文整理汇总了C#中Story.AsA方法的典型用法代码示例。如果您正苦于以下问题:C# Story.AsA方法的具体用法?C# Story.AsA怎么用?C# Story.AsA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Story的用法示例。


在下文中一共展示了Story.AsA方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: verify_receive_appropriate_success_message_when_user_provides_a_good_user_name_and_password

        public void verify_receive_appropriate_success_message_when_user_provides_a_good_user_name_and_password()
        {
            Story authenticateUserStory = new Story("Authenticate User");

            authenticateUserStory.AsA("USer with a valid user name and password")
                .IWant("supply my user name and password to the login form")
                .SoThat("I can authenticate to the application");

            authenticateUserStory
                .WithScenario("User provides a valid user name and password")
                .Given("My user name and password are ", "mmann", "validpassword_1", delegate(string userName, string password) { UserRepositoryFactory factory = _mock.DynamicMock<UserRepositoryFactory>();

                                                                                                                                 using (_mock.Record())
                                                                                                                                 {
                                                                                                                                    Expect.Call(factory.Create(userName, password))
                                                                                                                                        .Return(_mock.DynamicMock<IUserRepository>());
                                                                                                                                 }

                                                                                                                                 _user = factory.Create(userName, password); })
                .When("I authenticate the user", delegate {_service = _mock.DynamicMock<IAuthenticationService>();
                                                            using (_mock.Record())
                                                            {
                                                                Expect.Call(_service.Authenticate(_user))
                                                                    .Return(new AuthenticationStatus());
                                                            }
                                                           _authStatus = _service.Authenticate(_user);})
                .Then("I should receive an Authentication status of", Status.Success, delegate(Status expectedStatus) {Assert.AreEqual(expectedStatus, _authStatus.Status);});
        }
开发者ID:mmann2943,项目名称:berry-patch,代码行数:28,代码来源:AuthenticateUser.cs

示例2: ChangeUserPasswordObeyPasswordRule

        public void ChangeUserPasswordObeyPasswordRule()
        {
            _story = new Story("Change Memebers' password By IMembershipApi");

            _story.AsA("User")
              .IWant("to be able to change the password")
              .SoThat("I can use new password to login");

            _story.WithScenario("Change the password with a correct GUID")
                .Given("Create a new User with old password, but the new password doesn't follow the password rule", () =>
                {
                    _Uobject = _utils.CreateUserObject("Eunge Liu", true);

                    _oldpassword = "123Hello";

                    _newpassword = "0";

                    _membershipApi.Save(_Uobject, _oldpassword, "123Hello");

                    createdObjectIds.Add(_Uobject.UserId);

                })
                .When("I change the password ", () =>
                {

                })
                .Then("I can get Error Message from ChangePassword method",
                        () =>
                        {
                            typeof(ValidationException).ShouldBeThrownBy(() => _membershipApi.ChangePassword(_Uobject.UserId, _oldpassword, _newpassword));
                        });

            this.CleanUp();
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:34,代码来源:MemberChangePwdStory.cs

示例3: GetUserByCorrectGuid

        public void GetUserByCorrectGuid()
        {
            _story = new Story("Get Memebers By IMembershipApi");

            _story.AsA("User")
              .IWant("to be able to get members, and give the correct users' GUID")
              .SoThat("I can do somethings for members");

            IDictionary<Guid, UserObject> _Users = new Dictionary<Guid, UserObject>();

            _story.WithScenario("Get members by ImembershipApi with the correct userName")
                .Given("More than one correct GUID of users", () =>
                {
                    _Uobject = _utils.CreateUserObject("Eunge Liu", true);

                    _membershipApi.Save(_Uobject, "123Hello", "123Hello");

                    createdObjectIds.Add(_Uobject.UserId);

                })
                .When("I use the Get, I can get users ", () => _Uobject2 = _membershipApi.Get(_Uobject.UserId))
                .Then("The User2 is User1",
                        () =>
                        {
                            _Uobject.ShouldEqual(_Uobject2);
                        });

            this.CleanUp();
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:29,代码来源:GetMemberStory.cs

示例4: BulkGetUsersWithWrongGUID

        public void BulkGetUsersWithWrongGUID()
        {
            _story = new Story("Get Memebers By IMembershipApi");

            _story.AsA("User")
              .IWant("to be able to get members, and give wrong users' GUID")
              .SoThat("I can get nothing");

            IDictionary<Guid, UserObject> _Users = new Dictionary<Guid, UserObject>();

            Guid _temp = new Guid();

            _story.WithScenario("Get members by ImembershipApi with the only one correct Ids")
                .Given("only one correct GUID of user and fake one", () =>
                {
                    createdObjectIds.Add(_temp);
                })
                .When("I use the BulkGet, I can get users ", () => _Users = _membershipApi.BulkGet(createdObjectIds))
                .Then("The return a bunch of Users only contain null User ",
                        () =>
                        {
                            _Users[_temp].ShouldBeNull();
                        });

            //createdObjectIds.Remove(_temp);

            this.CleanUp();
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:28,代码来源:BulkGetMembersStory.cs

示例5: verify_receive_appropriate_error_message_when_user_provides_a_bad_user_name_or_password

        public void verify_receive_appropriate_error_message_when_user_provides_a_bad_user_name_or_password()
        {
            AuthenticationStatus authStatus = null;
            Story authenticateUserStory = new Story("Authenticate User");

            authenticateUserStory.AsA("Unauthenticated user")
                .IWant("supply my user name and password to the login form")
                .SoThat("I can  authenticate to the application");

            authenticateUserStory
                .WithScenario("User provides an invalid user name")
                .Given("My user name and password are ", "Big Daddy", "Gobldegook", delegate(string userName, string password) { UserRepositoryFactory factory = _mock.DynamicMock<UserRepositoryFactory>();

                                                                                                                                 using (_mock.Record())
                                                                                                                                 {
                                                                                                                                    Expect.Call(factory.Create(userName, password))
                                                                                                                                        .Return(_mock.DynamicMock<IUserRepository>());
                                                                                                                                 }

                                                                                                                                 _user = factory.Create(userName, password); })
                .When("I authenticate the user", delegate {_service = _mock.DynamicMock<IAuthenticationService>();
                                                            using (_mock.Record())
                                                            {
                                                                Expect.Call(_service.Authenticate(_user))
                                                                    .Return(new AuthenticationStatus(new Exception("Bad Username or Password")));
                                                            }
                                                           authStatus = _service.Authenticate(_user);})
                .Then("I should receive an Authentication status of", Status.Failed, delegate(Status expectedStatus) {Assert.AreEqual(expectedStatus, authStatus.Status);});
        }
开发者ID:mmann2943,项目名称:berry-patch,代码行数:29,代码来源:AuthenticateUser.cs

示例6: SaveMemeberStory

        public SaveMemeberStory()
        {
            base.GlobalSetup();

            _story = new Story("Save Memeber");
            _story.AsA("User")
              .IWant("to be able to save member status")
              .SoThat("I can update or create member info");

            _membershipApi = SpringContext.Current.GetObject<IMembershipApi>();
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:11,代码来源:SaveMemberStory.cs

示例7: SaveANewMemberWithEmptyProperties

        public void SaveANewMemberWithEmptyProperties()
        {
            _story = new Story("Save a Memeber By IMembershipApi");

            _story.AsA("User")
              .IWant("to be able to create a new member, but I don't assign value to it")
              .SoThat("I can get specific exception");

            _story.WithScenario("Save a new Member which have no value")
                .Given("the new member with nothing", () => { _Uobject = new UserObject(); })
                .When("I save this member", () => { })
                .Then("I Get an ArgumentNullException from IMembershipApi.Save()", () => typeof(ArgumentNullException).ShouldBeThrownBy(() => _membershipApi.Save(_Uobject, _password, _passwordAnswer)));
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:13,代码来源:SaveMemberStory.cs

示例8: Deposit_not_implemented_properly

        public void Deposit_not_implemented_properly()
        {
            var transferStory = new Story("Deposit to cash account");

            transferStory
                .AsA("savings account holder")
                .IWant("to deposit money into my cash account")
                .SoThat("I can have money for later");

            Account cash = null;

            transferStory
                .WithScenario("Savings account is in credit")
                .Given("my cash account balance is", 100,
                       accountBalance => { cash = new Account(accountBalance); })
                .When("I deposit into my cash account", 20, depositAmount => cash.Deposit(depositAmount))
                .Then("my cash account balance should be", 120,
                      expectedBalance => cash.Balance.ShouldEqual(expectedBalance));
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:19,代码来源:AccountSpecs.cs

示例9: Batch_must_occur_within_30_seconds

        public void Batch_must_occur_within_30_seconds()
        {
            var story = new Story("Must return an individual asset update in less than 30 seconds");
            story.AsA("Dispatcher")
                .IWant("To enter information into the system")
                .SoThat("I can see the result in visualised in the external system")

                .WithScenario("Item is updated into our internal system")
                .Given(() => DataForItem_IsUpdatedInInternalSystem(56))
                    .And(Narrative.Text("Database trigger has occured"))
                    .And(Narrative.Text("New item exists in the queue"))
                .When(Narrative.Exec("_mockConnector Service runs", StartTimer))
                    .And(() => GetFleedIdsFrom_Within_Secs("http://external.system.com", 20))
                    .And(() => HasMoreThan_Assets(310))
                    .And(() => GetsUpdatedItemsWithin_Secs(9))
                    .And(() => PutsSingleAsset_To_Within_Secs("281", "http://otherexternalsystem.com", 20))
                    .And(() => RetrievesNewDataFrom_ForAsset_XmlWithUtilisation_("http://otherexternalsystem.com", "281", 56))
                    .And(() => Within_Seconds(30));
            story.Assert();
        }
开发者ID:toddb,项目名称:DSL-Configuration-Sample,代码行数:20,代码来源:IndividualUpdateVisualisationTests.cs

示例10: Transfer_to_cash_account

        public void Transfer_to_cash_account()
        {
            Account savings = null;
            Account cash = null;

            var transferStory = new Story("Transfer to cash account");

            transferStory
                .AsA("savings account holder")
                .IWant("to transfer money from my savings account")
                .SoThat("I can get cash easily from an ATM");

            transferStory
                .WithScenario("Savings account is in credit")

                    .Given("my savings account balance is $balance", 100, accountBalance => { savings = new Account(accountBalance); })
                        .And("my cash account balance is $balance", 10, accountBalance => { cash = new Account(accountBalance); })
                    .When("I transfer $amount to cash account", 20, transferAmount => savings.TransferTo(cash, transferAmount))
                    .Then("my savings account balance should be $balance", 80, expectedBalance => savings.Balance.ShouldEqual(expectedBalance))
                        .And("my cash account balance should be $balance", 30, expectedBalance => cash.Balance.ShouldEqual(expectedBalance))

                    .Given("my savings account balance is 400")
                        .And("my cash account balance is 100")
                    .When("I transfer 100 to cash account")
                    .Then("my savings account balance should be 300")
                        .And("my cash account balance should be 200")

                    .Given("my savings account balance is 500")
                        .And("my cash account balance is 20")
                    .When("I transfer 30 to cash account")
                    .Then("my savings account balance should be 470")
                        .And("my cash account balance should be 50");

            transferStory
                .WithScenario("Savings account is overdrawn")

                    .Given("my savings account balance is  -20")
                        .And("my cash account balance is 10")
                    .When("I transfer 20 to cash account")
                    .Then("my savings account balance should be -20")
                        .And("my cash account balance should be 10");
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:42,代码来源:AccountSpecs.cs

示例11: Withdraw_from_savings_account_pending

        public void Withdraw_from_savings_account_pending()
        {
            var transferStory = new Story("Withdraw from savings account");

            transferStory
                .AsA("savings account holder")
                .IWant("to withdraw money from my savings account")
                .SoThat("I can pay for things with cash");

            transferStory
                .WithScenario("Savings account is in credit")
                    .Pending("ability to withdraw from accounts")

                    .Given("my savings account balance is 400")
                    .When("I withdraw $amount from my savings account", 100)
                    .Then("my savings account balance should be 300");
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:17,代码来源:AccountSpecs.cs

示例12: ChangeUserPasswordWithCorrectGuid

        public void ChangeUserPasswordWithCorrectGuid()
        {
            _story = new Story("Change Memebers' password By IMembershipApi");

            _story.AsA("User")
              .IWant("to be able to change the password")
              .SoThat("I can use new password to login");

            _story.WithScenario("Change the password with a correct GUID")
                .Given("Create a new with old password", () =>
                {
                    _Uobject = _utils.CreateUserObject("Eunge Liu", true);

                    _oldpassword = "123Hello";

                    _newpassword = "Hello123456";

                    _membershipApi.Save(_Uobject, _oldpassword, "123Hello");

                    createdObjectIds.Add(_Uobject.UserId);

                })
                .When("I change the password ", () =>
                        {
                    _membershipApi.ChangePassword(_Uobject.UserId, _oldpassword, _newpassword);
                        })
                .Then("The User can use new password to login",
                        () =>
                        {
                            _membershipApi.Login(_Uobject.UserName, _newpassword).ShouldEqual(LoginResults.Successful);
                        });

            this.CleanUp();
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:34,代码来源:MemberChangePwdStory.cs

示例13: SetUserToRoleAndUpdateStory

        public void SetUserToRoleAndUpdateStory()
        {
            _story = new Story("Create a Role By IRoleApi");
            IPlatformConfiguration platformConfiguration = SpringContext.Current.GetObject<IPlatformConfiguration>();
            IMembershipApi membershipApi = SpringContext.Current.GetObject<IMembershipApi>();
            IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();
            UserObject eunge = null;
            //IDictionary<Guid, RoleObject> _objects;
            _story.AsA("User")
              .IWant("to be able to set User to  Role")
              .SoThat("I can do something");

            _story.WithScenario("Set existing User to  an Existing Role By IRoleApi  ")
                .Given("Create several new role", () =>
                                                      {
                                                          OrganizationTypeObject department =
                                                              new OrganizationTypeObject
                                                                  {
                                                                      Name = "department",
                                                                      Domain = "Inc",
                                                                      Description = "department-desc"
                                                                  };
                                                          organizationApi.Save(department);
                                                          createdOrganizationTypeIds.Add(department.OrganizationTypeId);
                                                          powerAdministrators = new RoleObject
                                                                                    {
                                                                                        RoleName = "powerAdministrators",
                                                                                        Description =
                                                                                            "powerAdministrators-desc",
                                                                                        OrganizationTypeIds =
                                                                                            new Collection<Guid>
                                                                                                {
                                                                                                    department.
                                                                                                        OrganizationTypeId
                                                                                                }
                                                                                    };
                                                          business = new RoleObject
                                                                         {
                                                                             RoleName = "business",
                                                                             Description = "business-desc",
                                                                             OrganizationTypeIds =
                                                                                 new Collection<Guid> { department.OrganizationTypeId }
                                                                         };
                                                          roleApi.Save(powerAdministrators);
                                                          roleApi.Save(business);
                                                          createdRoleIds.AddRange(new Guid[]
                                                                                      {
                                                                                          powerAdministrators.RoleId,
                                                                                          business.RoleId
                                                                                      });

                                                      })
                .And("Create User", () =>
                                        {
                                            eunge = new UserObject
                                           {
                                               OrganizationId = platformConfiguration.Organization.OrganizationId,
                                               UserName = "eunge",
                                               DisplayName = "Eunge",
                                               Email = "[email protected]",
                                               Comment = "The author of BaoJianSoft.",
                                               IsApproved = true
                                           };

                                            membershipApi.Save(eunge, "password1", null);
                                            createdUserIds.Add(eunge.UserId);
                                        })
                .When("Set User to the Roles", () =>
                                                   {
                                                       roleApi.SetUserToRoles(eunge.UserId, new Guid[] { powerAdministrators.RoleId });
                                                       roleApi.SetUserToRoles(eunge.UserId, new Guid[] { powerAdministrators.RoleId, business.RoleId });
                                                       typeof(ArgumentException).ShouldBeThrownBy(() => roleApi.SetUserToRoles(new Guid(), new Guid[] { powerAdministrators.RoleId }));
                                                   })
                .Then("I get the relationship among these roles and User", () =>
                             {
                                 roleApi.FindByUserId(eunge.UserId).Count().ShouldEqual(2);
                                 roleApi.IsUserInRole(eunge.UserId, powerAdministrators.RoleId).ShouldBeTrue();
                                 roleApi.IsUserInRole(eunge.UserId, business.RoleId).ShouldBeTrue();
                             });

            _story.WithScenario("Update an Existing Role By IRoleApi  ")
                .Given("an existing Role", () => { })
                .When("Update the Role's Role Name", () => { powerAdministrators.RoleName = "NotAdmin"; roleApi.Save(powerAdministrators); })
                .Then("I still can get the Role by UserId",()=>
                                                               {
                                                                   var temp = roleApi.FindByUserId(eunge.UserId).Where(x => x.RoleName == powerAdministrators.RoleName);
                                                                   if(temp is RoleObject)
                                                                       ((RoleObject)temp).RoleName.ShouldEqual("NotAdmin");
                                                               });
            _story.WithScenario("Delete an Existing Role which assoicate with an existing User By IRoleApi  ")
                .Given("an existing Role", () => { })
                .When("Delete the Role", () => { roleApi.Delete(powerAdministrators.RoleId); })
                .Then("I  can get noting by userId", () =>
                {
                    powerAdministrators1 = roleApi.FindByUserId(eunge.UserId).Where(x => x.RoleName == powerAdministrators1.RoleName) as RoleObject;
                    powerAdministrators1.ShouldBeNull();
                });

            this.CleanUp();
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:100,代码来源:SetUserToRoles.cs

示例14: ExistApplication

        public void ExistApplication()
        {
            _story = new Story("Judge if the Application exists");

            _story.AsA("User")
              .IWant("to be able to Judge if the Application exists")
              .SoThat("I can decide to create the application or not");

            _story.WithScenario("Judge the application ")
                .Given("an unexisting application Name ", () =>
                {
                    _ApplicationObject = new ApplicationObject() { Description = "Haha", Name = "App" };
                })
                .When("I get this Application", () =>
                {
                    _applicationApi.Exists("App").ShouldBeFalse();
                })
                .Then(" I can create the object and judge if it exists ", () =>
                {
                    _applicationApi.Save(_ApplicationObject);

                    createdApplicationIds.Add(_ApplicationObject.Id);

                    _applicationApi.Exists("App").ShouldBeTrue();
                });
            this.CleanUp();
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:27,代码来源:GetAndExistApplicationStory.cs

示例15: GetApplication

        public void GetApplication()
        {
            _story = new Story("Get the Application");

            _story.AsA("User")
              .IWant("to be able to get an existing Application")
              .SoThat("I can modify the object");

            _story.WithScenario("Get the Application By correct application Name or application Id")
                .Given("an existing application Name or application Id",
                    () =>
                     {
                         _ApplicationObject = new ApplicationObject() { Description = "Application", Name = "App" };
                         _applicationApi.Save(_ApplicationObject);

                         createdApplicationIds.Add(_ApplicationObject.Id);
                     })
                .When("I get this Application",
                    () =>
                        {
                            _ApplicationObject1 = _applicationApi.Get(_ApplicationObject.Id);

                            _ApplicationObject2 = _applicationApi.Get(_ApplicationObject.Name);
                        })
                .Then("The Objects I get should be equal", () =>
                                                              {
                                                                  _ApplicationObject.Id.ShouldEqual(_ApplicationObject1.Id);
                                                                  //_ApplicationObject.Id.ShouldEqual(_ApplicationObject2.Id);

                                                              });

            this.CleanUp();
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:33,代码来源:GetAndExistApplicationStory.cs


注:本文中的Story.AsA方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。