コード例 #1
0
        public void Test_UserBuilderBuildWithDefaultsIsConsistent()
        {
            //setup/arrange
            User user1 = new UserBuilder().BuildWithDefaults();
            User user2 = new UserBuilder().BuildWithDefaults();

            //execute/act
            // no operation for this example

            //assert
            new UserAssertion().AreEqual(user1, user2, "Example Assertions");
        }
コード例 #2
0
        public void Test_CreateEmptyPolicyWithDefaultUserSucceeds_WithBuilder()
        {
            //setup/arrange
            Mockery mockery = new Mockery();
            User user = new UserBuilder().BuildWithDefaults();
            PolicyDAO policyDAO = mockery.NewMock<PolicyDAO>();
            Expect.Once.On(policyDAO).Method("Save").WithAnyArguments();
            PolicyManager manager = new PolicyManagerImpl(policyDAO);

            //execute/act
            Policy policy = manager.CreateEmptyPolicy(user);

            //assert
            mockery.VerifyAllExpectationsHaveBeenMet();
            Assert.AreSame(user, policy.Holder, "holder should be user we created for");
            Assert.AreEqual(0, policy.Coverages.Count, "coverages should be zero");
        }
コード例 #3
0
        public void Test_CreateEmptyPolicyWithCustomUserSucceeds_WithBuilder()
        {
            //setup/arrange
            Mockery mockery = new Mockery();
            User user = new UserBuilder().WithUserName("customuser").Build();                   //this would require something special in the fixture, or more code here
            PolicyDAO policyDAO = mockery.NewMock<PolicyDAO>();
            Expect.Once.On(policyDAO).Method("Save").WithAnyArguments();
            PolicyManager manager = new PolicyManagerImpl(policyDAO);

            //execute/act
            Policy policy = manager.CreateEmptyPolicy(user);

            //assert
            mockery.VerifyAllExpectationsHaveBeenMet();
            Assert.AreSame(user, policy.Holder, "holder should be user we created for");
            Assert.AreEqual(user.UserName, policy.Holder.UserName, "usernames should be equal");
            Assert.AreEqual(0, policy.Coverages.Count, "coverages should be zero");
        }
コード例 #4
0
 public void Setup()
 {
     user1 = new UserBuilder().BuildWithDefaults();
     user2 = new UserBuilder().BuildWithDefaults();
 }