Skip to content

Instantly share code, notes, and snippets.

@wildaces215
Created August 15, 2019 15:43
Show Gist options
  • Select an option

  • Save wildaces215/170486789231ef8c8645d8ee4e54ce0c to your computer and use it in GitHub Desktop.

Select an option

Save wildaces215/170486789231ef8c8645d8ee4e54ce0c to your computer and use it in GitHub Desktop.
using System;
namespace SimpleProduct
{
public class Product
{
public int q;
public float pr;
public int i;
public Product(int quantity,float price, int id)
{
q = quantity;
pr = price;
i = id;
}
public int getQuantity()
{
return q;
}
public float getPrice()
{
return pr;
}
public int getId()
{
return i;
}
public float changePrice(float newPrice)
{
newPrice = pr;
return pr;
}
public int quantity(int newQuality)
{
return q;
}
}
}
using NUnit.Framework;
using System.Collections.Generic;
namespace SimpleProduct
{
[TestFixture]
public class SimpleProductTest
{
Product testProductOne = new Product(45, (float)34.99, 1);
Product testProductTwo = new Product(68, (float)39.99, 2);
Product testProductThree = new Product(123, (float)99.99, 3);
List<Product> productArray = new List<Product>;
productArray.Add(testProductOne);
//Test for get Functions
[Test]
public void _getPrice() {
Assert.AreEqual((float)34.99, testProductOne.getPrice());
Assert.AreEqual((float)39.99, testProductTwo.getPrice());
Assert.AreEqual((float)99.99, testProductThree.getPrice());
}
[Test]
public void _getQuantity()
{
Assert.AreEqual(45,testProductOne.getQuantity());
Assert.AreEqual(68,testProductTwo.getQuantity());
Assert.AreEqual(123,testProductThree.getQuantity());
}
[Test]
public void _getId()
{
Assert.AreEqual(1, testProductOne.getId());
Assert.AreEqual(2,testProductTwo.getId());
Assert.AreEqual(3, testProductThree.getId());
}
//Changing of values within Object.
//[Test]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment