本文整理汇总了C#中Story.WithScenario方法的典型用法代码示例。如果您正苦于以下问题:C# Story.WithScenario方法的具体用法?C# Story.WithScenario怎么用?C# Story.WithScenario使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Story
的用法示例。
在下文中一共展示了Story.WithScenario方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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);});
}
示例3: 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();
}
示例4: 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);});
}
示例5: ChangeUserPasswordWithWrongGuid
public void ChangeUserPasswordWithWrongGuid()
{
_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");
Guid _temp = new Guid();
_story.WithScenario("Change the password with a Incorrect GUID")
.Given("Create a new with old password", () =>
{
_oldpassword = "123Hello";
_newpassword = "Hello123456";
createdObjectIds.Add(_temp);
})
.When("I change the password ", () =>
{
})
.Then("I can get Error Message from ChangePassword method",
() =>
{
typeof(NullReferenceException).ShouldBeThrownBy(()=>_membershipApi.ChangePassword(_temp, _oldpassword, _newpassword));
});
this.CleanUp();
}
示例6: BulkGetOrganizationTypes
public void BulkGetOrganizationTypes()
{
_story = new Story("Find More than one OrganizationTypes By IOrganizationApi");
_story.AsA("User")
.IWant("to be able to find more than one existing OrganizationTypes")
.SoThat("I can get the OrganizationTypes");
IList<string> domains = new List<string>();
domains.Add("Inc");
domains.Add("Inc2");
domains.Add("Customer");
IEnumerable<OrganizationTypeObject> _temp = null;
_story.WithScenario("find more than OrganizationTypes ")
.Given("the domain of the organizationtype", () =>
{
_OrganTypeObject1 = _utils.CreateOrganizationTypeOject("Depart1","Inc");
_organizationApi.Save(_OrganTypeObject1);
createdOrganizationTypeIds.Add(_OrganTypeObject1.OrganizationTypeId);
//_OrganTypeObject2 = _utils.CreateOrganizationTypeOject("Depart2", "Inc");
//_organizationApi.Save(_OrganTypeObject2);
//createdOrganizationTypeIds.Add(_OrganTypeObject2.OrganizationTypeId);
_OrganTypeObject3 = _utils.CreateOrganizationTypeOject("Depart3", "Customer");
_organizationApi.Save(_OrganTypeObject3);
createdOrganizationTypeIds.Add(_OrganTypeObject3.OrganizationTypeId);
})
.When("I bulkget organizations", () =>
{
_temp = _organizationApi.FindOrganizationTypes(domains);
})
.Then("I can get all the organizations in this List", () =>
{
_temp.Contains(_OrganTypeObject1).ShouldBeTrue();
_temp.Contains(_OrganTypeObject3).ShouldBeTrue();
});
this.CleanUp();
}
示例7: GetOrganizationWithCorrectGuidAndCorrectName
public void GetOrganizationWithCorrectGuidAndCorrectName()
{
_story = new Story("Find a Organization By IOrganizationApi");
_story.AsA("User")
.IWant("to be able to find an existing Organization")
.SoThat("I can modify the object");
_story.WithScenario("find an existing Organization ")
.Given("the GUID and Name of the organization", () =>
{
_OrganTypeObject1 = _utils.CreateOrganizationTypeOject("Depart","Inc");
_organizationApi.Save(_OrganTypeObject1);
createdOrganizationTypeIds.Add(_OrganTypeObject1.OrganizationTypeId);
_OrganObject1 = _utils.CreateOrganizationObject(_OrganTypeObject1.OrganizationTypeId, "hangzhou1", "hangzhou1");
_organizationApi.Save(_OrganObject1);
createdOrganizationIds.Add(_OrganObject1.OrganizationId);
})
.When("I get the organization", () =>
{
_OrganObject2 = _organizationApi.GetOrganization(_OrganObject1.OrganizationId);
_OrganObject3 = _organizationApi.GetOrganizationByName(_OrganObject1.OrganizationName);
_OrganObject4 = _organizationApi.GetOrganizationByCode(_OrganObject1.OrganizationCode);
})
.Then("I Get two same Organization", () =>
{
_OrganObject2.ShouldEqual(_OrganObject1);
_OrganObject2.ShouldEqual(_OrganObject3);
_OrganObject2.ShouldEqual(_OrganObject4);
});
this.CleanUp();
}
示例8: 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();
}
示例9: GetUserByInCorrectUserName
public void GetUserByInCorrectUserName()
{
_story = new Story("Get Memebers By IMembershipApi");
_story.AsA("User")
.IWant("to be able to get members, and give the incorrect users' userName")
.SoThat("I can get Error Message");
_story.WithScenario("Get members by ImembershipApi with the Incorrect userName")
.Given("More than one correct GUID of users", () =>
{
})
.When("I use the Get, I can get users ", () => _Uobject2 = _membershipApi.Get("Wild Name"))
.Then("The return is null",
() =>
{
_Uobject2.ShouldBeNull();
});
this.CleanUp();
}
示例10: 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));
}
示例11: DoesInstanceConnect2
public void DoesInstanceConnect2()
{
Story instanceConnectStory = new Story("Connect to instance");
QuartzAdmin.web.Models.InstanceRepository instanceRepo = new QuartzAdmin.web.Models.InstanceRepository();
QuartzAdmin.web.Models.InstanceModel instance = null;
Quartz.IScheduler sched = null;
instanceConnectStory
.AsA("System Admin")
.IWant("to connect to a running quartz instance")
.SoThat("I can perform admin functions");
instanceConnectStory
.WithScenario("Perform connection to instance")
.Given("the instance name is", "Instance1", delegate(string instanceName) { instance = instanceRepo.GetInstance(instanceName); })
.When("the connection is attempted", delegate() { sched = instance.GetQuartzScheduler(); })
.Then("the connection is not null", delegate() { Assert.IsNotNull(sched); });
}
示例12: HierarchyTreeStory
public void HierarchyTreeStory()
{
_story = new Story("Save the Hierarchy data And Bind to Organization Type");
_story.AsA("User")
.IWant("Create Hierarchy Data")
.SoThat("I can bind the Hierarchy to the object that have cascade relationship");
_story.WithScenario("Save Hierarchy Data")
.Given("a Hierarchy data which is new ", () =>
{
_HierarchyDataObject = new HierarchyDataObject()
{
Code = "1111",
Description = "Sample",
HierarchyType = "Tree",
Name = "Root"
};
_HierarchyApi.Save(_HierarchyDataObject);
createHierarchyIds.Add(_HierarchyDataObject.Id);
})
.And("create More than one Organization ", () =>
{
_OrganizationTypeObject1 = _Organutils.CreateOrganizationTypeOject("Root", "Inc");
_OrganizationApi.Save(_OrganizationTypeObject1);
createdOrganizationTypeIds.Add(_OrganizationTypeObject1.OrganizationTypeId);
_OrganizationObject1 = _Organutils.CreateOrganizationObject(_OrganizationTypeObject1.OrganizationTypeId, "Tim", "sh");
_OrganizationObject2 = _Organutils.CreateOrganizationObject(_OrganizationTypeObject1.OrganizationTypeId, "Euge", "sc");
_OrganizationApi.Save(_OrganizationObject1);
_OrganizationApi.Save(_OrganizationObject2);
createdOrganizationIds.Add(_OrganizationObject1.OrganizationId);
createdOrganizationIds.Add(_OrganizationObject2.OrganizationId);
})
.When("Have the Hierarchy Data", () =>
{
_HierarchyDataObject1 = _HierarchyApi.GetHierarchyData(_HierarchyDataObject.Id);
_HierarchyDataObject2 = _HierarchyApi.GetHierarchyData("Tree", "Root");
_HierarchyDataObject1.Id.ShouldEqual(_HierarchyDataObject.Id);
_HierarchyDataObject2.Id.ShouldEqual(_HierarchyDataObject.Id);
})
.Then("I can use the Hierarchy Data to bind to Organization object", () =>
{
_RelationshipObject1 = new RelationshipObject()
{
ReferenceObjectId = _HierarchyDataObject.Id,
RelationshipType = "Tree"
};
_RelationShipApi.Save(_OrganizationObject1.OrganizationId, _RelationshipObject1);
_RelationShipApi.Save(_OrganizationObject2.OrganizationId, _RelationshipObject1);
_RelationshipObject2 = _RelationShipApi.GetOneToOne(_OrganizationObject1.OrganizationId, _RelationshipObject1.RelationshipType);
_RelationshipObject3 = _RelationShipApi.GetOneToOne(_OrganizationObject2.OrganizationId, _RelationshipObject1.RelationshipType);
_RelationshipObject2.ReferenceObjectId.ShouldEqual(_RelationshipObject3.ReferenceObjectId);
_RelationshipObject2.Ordinal.ShouldEqual(_RelationshipObject3.Ordinal);
})
.WithScenario("How to create Hierarchy in Organization")
.Given("Remove the relationship between Organ1 and Organ2", () =>
{
_RelationShipApi.Remove(_OrganizationObject1.OrganizationId);
_RelationShipApi.Remove(_OrganizationObject2.OrganizationId, "Tree");
})
.And("Create a child Hierarchy data ", () =>
{
_HierarchyDataObject2 = new HierarchyDataObject()
{
Code = "1111",
Description = "Sample",
HierarchyType = "Tree",
Name = "Leaf",
ParentHierarchyDataId = _HierarchyDataObject.Id
};
_HierarchyApi.Save(_HierarchyDataObject2);
})
.When("I add the hierarchy data to Organization", () =>
{
_OrganizationObject1.Hierarchies.Add("Tree", _HierarchyDataObject.Id);
_OrganizationObject2.Hierarchies.Add("Tree", _HierarchyDataObject2.Id);
_OrganizationApi.Save(_OrganizationObject1);
_OrganizationApi.Save(_OrganizationObject2);
})
.Then("I can get children HierarchyData by Hierarchy", () =>
{
_HierarchyDataObject1 = null;
_HierarchyDataObject1 = _HierarchyApi.GetImmediateChildren("Tree", _HierarchyDataObject.Id).FirstOrDefault();
_HierarchyDataObject1.Id.ShouldEqual(_HierarchyDataObject2.Id);
})
.WithScenario("Delete the children Hierarchy Data")
.Given("an Existing parent Hierarchy Data and an existing child", () => { })
//.........这里部分代码省略.........
示例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();
}
示例14: MemberLoginWithCorrectUserNameAndPwd
public void MemberLoginWithCorrectUserNameAndPwd()
{
_story = new Story("Login with UserName and Password");
_story.AsA("User")
.IWant("to be able to login ")
.SoThat("I can use features");
_story.WithScenario("login with a correct username and password")
.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 login", () =>
{
_ret = _membershipApi.Login(_Uobject.UserName, _oldpassword);
})
.Then("The User can get Successful Logon",
() =>
{
_ret.ShouldEqual(LoginResults.Successful);
});
this.CleanUp();
}
示例15: SaveRolesStory
public void SaveRolesStory()
{
_story = new Story("Create a Role By IRoleApi");
//IDictionary<Guid, RoleObject> _objects;
_story.AsA("User")
.IWant("to be able to create a Role")
.SoThat("I can do something");
_story.WithScenario("create a Role By IRoleApi including Create the Same Name;Same Domain; Same Description; Empty Name; ")
.Given("Create several new roles", () =>
{
IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();
OrganizationTypeObject department = new OrganizationTypeObject { Name = "department", Domain = "Inc", Description = "department-desc" };
organizationApi.Save(department);
createdOrganizationTypeIds.Add(department.OrganizationTypeId);
OrganizationTypeObject customer = new OrganizationTypeObject { Name = "customer", Domain = "Customer", Description = "customer-desc" };
organizationApi.Save(customer);
createdOrganizationTypeIds.Add(customer.OrganizationTypeId);
powerAdministrators = new RoleObject { RoleName = "", Description = "powerAdministrators-desc", OrganizationTypeIds = new Collection<Guid> { department.OrganizationTypeId }, Predefined = true };
business = new RoleObject { RoleName = "business", Description = "business-desc", OrganizationTypeIds = new Collection<Guid> { department.OrganizationTypeId } };
customers = new RoleObject { RoleName = "customers", Description = "customers-desc", OrganizationTypeIds = new Collection<Guid> { customer.OrganizationTypeId } };
})
.When("I save this member", () =>
{
//roleApi.Save(powerAdministrators);
roleApi.Save(business);
roleApi.Save(customers);
//createdRoleIds.Add(powerAdministrators.RoleId);
createdRoleIds.Add(business.RoleId);
createdRoleIds.Add(customers.RoleId);
})
.Then("I get these roles", () =>
{
typeof(ArgumentNullException).ShouldBeThrownBy(()=>roleApi.Save(powerAdministrators));
});
this.CleanUp();
}