public void CancelApplication_Fails_WhenStateIsNotMakeAppointmentOrIsNotPersonalAppearance(uint state) { // Setup incorrect sender. this.mockPersistentState.Setup(s => s.GetAddress(nameof(PassportApplication.Applicant))).Returns(ApplicantAddress); this.mockContractState.Setup(s => s.Message.Sender).Returns(ApplicantAddress); var contract = new PassportApplication(this.mockContractState.Object, AppId, ProviderAddress, RefNumber); // Setup set state. this.mockPersistentState.Setup(s => s.GetUInt32(nameof(PassportApplication.State))).Returns(state); // Attempt CancelApplication when state is not MakeAppointment or PersonalAppearance should fail. Assert.Throws <SmartContractAssertException>(() => contract.CancelApplication()); }
public void CancelApplication_Succeeds_WhenStateIsMakeAppointment() { // Setup incorrect sender. this.mockPersistentState.Setup(s => s.GetAddress(nameof(PassportApplication.Applicant))).Returns(ApplicantAddress); this.mockContractState.Setup(s => s.Message.Sender).Returns(ApplicantAddress); var contract = new PassportApplication(this.mockContractState.Object, AppId, ProviderAddress, RefNumber); // Setup set state. this.mockPersistentState.Setup(s => s.GetUInt32(nameof(PassportApplication.State))).Returns((uint)PassportApplication.StateType.MakeAppointment); contract.CancelApplication(); // Attempt CancelApplication when state is MakeAppointment should succeed. this.mockPersistentState.Verify(s => s.SetUInt32(nameof(PassportApplication.State), (uint)PassportApplication.StateType.CancelledApplication)); }