public void SendMailToCustomer_WhenCalled_ReturnTrue() { var customerComm = new CustomerComm(moqMailSender.Object); var result = customerComm.SendMailToCustomer(); Assert.That(result, Is.EqualTo(true)); }
public void SendMailToCustomer_ValidInputs_ExpectedTrue(string toAddress, string msg) { _mailSender.Setup(p => p.SendMail(toAddress, msg)).Returns(true); CustomerComm customerComm = new CustomerComm(_mailSender.Object); var result = customerComm.SendMailToCustomer(); Assert.IsTrue(result); }
public void SendMailToCustomer_WhenCalled_ReturnTrue(string toaddress, string name, bool expected) { mock = new Mock <IMailSender>(); mock.Setup(p => p.SendMail(toaddress, name)).Returns(expected); customer = new CustomerComm(mock.Object); bool actual = customer.SendMailToCustomer(toaddress, name); Assert.AreEqual(expected, actual); }
public void TestSendMail(string mail, string message, bool expectedResult) { mock = new Mock <IMailSender>(MockBehavior.Strict); systemUnderTest = new CustomerComm(mock.Object); mock.Setup(p => p.SendMail(mail, message)).Returns(expectedResult); bool actual = systemUnderTest.SendMailToCustomer(); Assert.AreEqual(actual, expectedResult); }
public void SendMail_with_CustomerComm(string toAddress, string message, bool expected) { mock = new Mock <IMailSender>(MockBehavior.Loose); cc = new CustomerComm(mock.Object); mock.Setup(p => p.SendMail(toAddress, message)).Returns(expected); bool actual = cc.SendMailToCustomer(); Assert.AreEqual(expected, actual); }
public void Test1() { Mock <MailSend> obj = new Mock <MailSender>(); obj.Setup(x => x.SendMail("*****@*****.**", "Hii,Welcome")).Returns(true); CustomerComm cust = new CustomerComm(obj.Object); bool isInserted = cust.SendMailToCustomer(); Assert.AreEqual(isInserted, true); }
public void OneTimeSetUp(string toaddress, string name, bool expected) { mock = new Mock <IMailSender>(); mock.Setup(p => p.SendMail(toaddress, name)).Returns(expected); obj = new CustomerComm(mock.Object); bool actual = obj.SendMailToCustomer(toaddress, name); Assert.AreEqual(expected, actual); }
public void CommercialChargeWithHighUsageTestSucc() { //Arrange decimal usage = 2000m; //high usage defined as > 1000 kWh CustomerComm customerComm = new CustomerComm(accountNumber, accountName, custType, usage); decimal expectedCharge = 105; decimal actualCharge; //Act actualCharge = customerComm.CalculateCharge(); //Assert Assert.AreEqual(expectedCharge, actualCharge); }
public void init() { mockMailSender = new Mock <IMailSender>(); mockMailSender.Setup(m => m.SendMail(It.IsAny <string>(), It.IsAny <string>())).Returns(true); customer = new CustomerComm(mockMailSender.Object); }
public void Init() { _mock = new Mock <IMailSender>(MockBehavior.Strict); customerComm = new CustomerComm(_mock.Object); }
public void Init() { mockMailSender = new Mock <IMailSender>(); customerComm = new CustomerComm(mockMailSender.Object); }
// calculate and display bill to pay private void btnCalculate_Click(object sender, EventArgs e) { // local declaration decimal kWh = 0m; //input: kWh used for residential or commercial customers decimal kWhPeak = 0m; //input: kWh used for industrial customers during peak hours decimal kWhOff = 0m; //input: kWh used for industrial customers during off-peak hours string customer; //input: customer type char custType; //customer type (R, C, or I) // obtain type of customer input from dropbox list customer = cboCustomer.Text; //assign customer type switch (customer) { case "Residential": //focus on the input box txtAccountNo.Focus(); //validate user input for kWh used if (validator.IsProvided(txtAccountNo, "Account Number") && validator.IsNonZeroPositiveInt(txtAccountNo, "Account Number") && validator.IsProvided(txtCustomerName, "Customer Name") && validator.IsString(txtCustomerName, "Customer Name") && validator.IsProvided(txtkWh, "Residential usage") && validator.IsNonNegativeInt(txtkWh, "Residential Usage")) { //assign custType custType = 'R'; //obtain input kWh = Convert.ToDecimal(txtkWh.Text); //create a Customer Object using data from text boxes Customer c = new CustomerRes(Convert.ToInt32(txtAccountNo.Text), txtCustomerName.Text, custType, kWh); //display charge amount in appropriate text box txtBill.Text = c.CalculateCharge().ToString("c"); //add it to the list and display customers.Add(c); //DisplayCustomers(); } break; case "Commercial": //focus on the input box txtAccountNo.Focus(); //validate user input for kWh used if (validator.IsProvided(txtAccountNo, "Account Number") && validator.IsNonZeroPositiveInt(txtAccountNo, "Account Number") && validator.IsProvided(txtCustomerName, "Customer Name") && validator.IsString(txtCustomerName, "Customer Name") && validator.IsProvided(txtkWh, "Commercial usage") && validator.IsNonNegativeInt(txtkWh, "Commercial Usage")) { //assign custType custType = 'C'; //obtain input kWh = Convert.ToDecimal(txtkWh.Text); //create a Customer Object using data from text boxes Customer c = new CustomerComm(Convert.ToInt32(txtAccountNo.Text), txtCustomerName.Text, custType, kWh); //display charge amount in appropriate text box txtBill.Text = c.CalculateCharge().ToString("c"); //add it to the list and display customers.Add(c); //DisplayCustomers(); } break; case "Industrial": //validate user input for kWh used if (validator.IsProvided(txtAccountNo, "Account Number") && validator.IsNonZeroPositiveInt(txtAccountNo, "Account Number") && validator.IsProvided(txtCustomerName, "Customer Name") && validator.IsString(txtCustomerName, "Customer Name") && validator.IsProvided(txtkWhPeak, "Industrial peak hours usage") && validator.IsNonNegativeInt(txtkWhPeak, "Industrial peak hours usage") && validator.IsProvided(txtkWhOff, "Industrial off-peak hours usage") && validator.IsNonNegativeInt(txtkWhOff, "Industrial off-peak hours usage")) { //assign custType custType = 'I'; //obtain input(s) kWhPeak = Convert.ToDecimal(txtkWhPeak.Text); kWhOff = Convert.ToDecimal(txtkWhOff.Text); //create a Customer Object using data from text boxes Customer c = new CustomerInd(Convert.ToInt32(txtAccountNo.Text), txtCustomerName.Text, custType, kWhPeak, kWhOff); //display charge amount in appropriate text box txtBill.Text = c.CalculateCharge().ToString("c"); //add it to the list and display customers.Add(c); } break; default: break; } }
public void Init() { mock = new Mock <IMailSender>(MockBehavior.Strict); systemUnderTest = new CustomerComm(mock.Object); }