def test_assigning_a_material(): # Given s = MockShape() m = Material() m.ambient = 1 # When s.material = m # Then assert s.material == m
def test_lighting_with_a_pattern_applied(): # Given m = Material() m.pattern = StripePattern(Color(1, 1, 1), Color(0, 0, 0)) m.ambient = 1 m.diffuse = 0 m.specular = 0 eyev = Vector(0, 0, -1) normalv = Vector(0, 0, -1) light = PointLight(Point(0, 0, -10), Color(1, 1, 1)) object = Sphere() # When c1 = m.lighting(object, light, Point(0.9, 0, 0), eyev, normalv) c2 = m.lighting(object, light, Point(1.1, 0, 0), eyev, normalv) # Then assert c1 == Color(1, 1, 1) assert c2 == Color(0, 0, 0)
def test_material_equality_with_different_materials(): m1 = Material() m2 = Material() m2.ambient = 1 assert m1 != m2