public void TestPrepararPlato() { var mockBasculaService = new Mock <IBasculaService>(); var mockCocinaService = new Mock <ICocinaService>(); mockBasculaService.Setup(bascula => bascula.Pesar(It.IsAny <Alimento>())) .Returns((Alimento p) => p.Peso); mockBasculaService.Setup(bascula => bascula.Pesar(It.IsAny <Alimento>())) .Returns((Alimento p) => p.Peso); mockCocinaService.Setup(cocina => cocina.Calentar(It.IsAny <Alimento>(), It.IsAny <Alimento>())) .Callback((Alimento p1, Alimento p2) => { p1.Calentado = true; p2.Calentado = true; }); sut = new TurbomixService(mockBasculaService.Object, mockCocinaService.Object, null); Plato resultado = sut.PrepararPlato(mAlimento1, mAlimento2); mAlimentoReceta1.Peso = 1.5F; mAlimentoReceta2.Peso = 5F; mockBasculaService.Verify(bascula => bascula.Pesar(It.IsAny <Alimento>()), Times.AtLeast(1)); mockCocinaService.Verify(cocina => cocina.Calentar(It.IsAny <Alimento>(), It.IsAny <Alimento>()), Times.AtLeast(1)); Plato mPlato = new Plato(mAlimentoReceta1, mAlimentoReceta2); Assert.AreEqual(mPlato, resultado); }
public void TestPrepararPlato() { IBascula basculaService = new BasculaService(); ICocina cocinaService = new CocinaService(); TurbomixService sut = new TurbomixService(basculaService, cocinaService); Alimento mAlimento1 = new Alimento(); mAlimento1.Nombre = "Curry"; mAlimento1.Peso = 1.5F; Alimento mAlimento2 = new Alimento(); mAlimento2.Nombre = "Queso"; mAlimento2.Peso = 5F; Receta mReceta = new Receta(); mReceta.NombreAlimento1 = "Curry"; mReceta.NombreAlimento2 = "Queso"; mReceta.Peso1 = 1.5F; mReceta.Peso2 = 5F; Plato resultado = sut.PrepararPlato(mAlimento1, mAlimento2, mReceta); Assert.IsTrue(resultado is Plato); }
public void TestPrepararPlatoConReceta() { IBascula basculaService = new BasculaService(); ICocina cocinaService = new CocinaService(); TurbomixService sut = new TurbomixService(basculaService, cocinaService); Alimento mAlimento1 = new Alimento(0.2f, false); mAlimento1.Nombre = "Curry"; Alimento mAlimento2 = new Alimento(0.4f, false); mAlimento2.Nombre = "Queso"; Receta receta = new Receta(mAlimento1, mAlimento2); sut.PrepararPlatoConReceta(mAlimento1, mAlimento2, receta); }
public void TestPrepararPlato() { var mockBasculaService = new Mock <IBasculaService>(); var mockCocinaService = new Mock <ICocinaService>(); mockBasculaService.Setup(bascula => bascula.Pesar(It.IsAny <Alimento>())) .Returns((Alimento p) => p.Peso); mockBasculaService.Setup(bascula => bascula.Pesar(It.IsAny <Alimento>())) .Returns((Alimento p) => p.Peso); mockCocinaService.Setup(cocina => cocina.Calentar(It.IsAny <Alimento>(), It.IsAny <Alimento>())) .Callback( (Alimento p1, Alimento p2) => { p1.Calentado = true; p2.Calentado = true; } ); IBasculaService basculaService = mockBasculaService.Object; ICocinaService cocinaService = mockCocinaService.Object; TurbomixService sut = new TurbomixService(basculaService, cocinaService, null); Alimento mAlimento1 = new Alimento(); mAlimento1.Nombre = "Curry"; mAlimento1.Peso = 1.5F; Alimento mAlimento2 = new Alimento(); mAlimento2.Nombre = "Queso"; mAlimento1.Peso = 5F; Plato resultado = sut.PrepararPlato(mAlimento1, mAlimento2); //Verificaciones mockBasculaService.Verify(bascula => bascula.Pesar(It.IsAny <Alimento>()), Times.AtLeast(2)); mockCocinaService.Verify(cocina => cocina.Calentar(It.IsAny <Alimento>(), It.IsAny <Alimento>()), Times.Once()); Plato mPlato = new Plato(mAlimento1, mAlimento2); Assert.AreEqual(mPlato, resultado); }
public void TestPrepararPlato() { IBasculaService basculaService = new BasculaService(); ICocinaService cocinaService = new CocinaService(); TurbomixService sut = new TurbomixService(basculaService, cocinaService, null); Alimento mAlimento1 = new Alimento(); mAlimento1.Nombre = "Curry"; mAlimento1.Peso = 1.5F; Alimento mAlimento2 = new Alimento(); mAlimento2.Nombre = "Queso"; mAlimento1.Peso = 5F; Plato resultado = sut.PrepararPlato(mAlimento1, mAlimento2); Plato mPlato = new Plato(mAlimento1, mAlimento2); Assert.AreEqual(mPlato, resultado); }
public void TestPrepararPlato() { IBascula basculaService = new BasculaService(); ICocina cocinaService = new CocinaService(); TurbomixService sut = new TurbomixService(basculaService, cocinaService); Alimento mAlimento1 = new Alimento(); mAlimento1.Nombre = "Espagueti"; mAlimento1.Peso = 1.5F; Alimento mAlimento2 = new Alimento(); mAlimento2.Nombre = "Tomate"; mAlimento1.Peso = 5F; Receta recetaEspaguetis = new Receta(mAlimento1, mAlimento2); Plato resultado = sut.PrepararPlato(mAlimento1, mAlimento2, recetaEspaguetis); Plato mPlato = new Plato(mAlimento1, mAlimento2); Assert.AreEqual(mPlato, resultado); }
public void Init() { IBasculaService basculaService = new BasculaService(); ICocinaService cocinaService = new CocinaService(); sut = new TurbomixService(basculaService, cocinaService, null); mAlimento1 = new Alimento(); mAlimento1.Nombre = "Curry"; mAlimento1.Peso = 1.5F; mAlimento2 = new Alimento(); mAlimento2.Nombre = "Queso"; mAlimento2.Peso = 5F; mAlimentoReceta1 = new Alimento(); mAlimentoReceta1.Nombre = "Curry"; mAlimentoReceta1.Peso = 1.4F; mAlimentoReceta1.Calentado = true; mAlimentoReceta2 = new Alimento(); mAlimentoReceta2.Nombre = "Queso"; mAlimentoReceta2.Peso = 3F; mAlimentoReceta2.Calentado = true; receta = new Receta(mAlimentoReceta1, mAlimentoReceta2); }