public void Get_Pie_Details() { // Arrange var pie = new Pie { PieId = 1, Name = "Strawberry Pie", Price = 15.95M, ShortDescription = "Lorem Ipsum" }; var pieRepo = new Mock <IPieRepository>(); pieRepo.Setup(c => c.GetPieById(It.IsAny <int>())).Returns(pie); var categoryRepo = new Mock <ICategoryRepository>(); var controller = new PieController(pieRepo.Object, categoryRepo.Object); // Act var result = controller.Details(It.IsAny <int>()); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <Pie>( viewResult.Model); Assert.Equal("Strawberry Pie", model.Name); }
public void Pie_List_Check_Pies() { // Arrange var pie = new List <Pie> { new Pie { PieId = 1, Name = "Strawberry Pie", Price = 15.95M, ShortDescription = "Lorem Ipsum" } }; var pieRepo = new Mock <IPieRepository>(); pieRepo.Setup(c => c.AllPies).Returns(pie); var categoryRepo = new Mock <ICategoryRepository>(); var controller = new PieController(pieRepo.Object, categoryRepo.Object); // Act var result = controller.List(""); // Assert //var viewResult = Assert.IsType<PiesListViewModel>(result.Model); var model = Assert.IsAssignableFrom <PiesListViewModel>( result.Model); //var model= result.Model as PiesListViewModel; var pieFromMock = model.Pies.FirstOrDefault(); Assert.Single(model.Pies); Assert.Equal("Strawberry Pie", pieFromMock?.Name); }
public void Pie_List_Check_Current_Category() { // Arrange var pieRepo = new Mock <IPieRepository>(); pieRepo.Setup(c => c.AllPies).Returns(It.IsAny <List <Pie> >()); var categoryRepo = new Mock <ICategoryRepository>(); var category = new Category { CategoryId = 1, CategoryName = "Seasonal pies", Description = "Get in the mood for a seasonal pie" }; var controller = new PieController(pieRepo.Object, categoryRepo.Object); // Act var result = controller.List(category.CategoryName); // Assert var viewResult = Assert.IsType <PiesListViewModel>(result.Model); var model = Assert.IsAssignableFrom <PiesListViewModel>( viewResult); //var model= result.Model as PiesListViewModel; Assert.Equal("Cheese Cakes", model.CurrentCategory); }
public void Setup() { _PieRepository = new Mock <IPieRepository>(); _CategoryRepository = new Mock <ICategoryRepository>(); _IWebHostEnvironment = new Mock <IWebHostEnvironment>(); _PieController = new PieController(_PieRepository.Object, _CategoryRepository.Object, _IWebHostEnvironment.Object); }
void Start() { if (!descriptionText) { descriptionText = GameObject.Find("ItemDescription").GetComponent <Text>(); } pieController = GameObject.Find("ItemDescriptionPie").GetComponent <PieController>(); }
public void SetUp() { _pies = BuildPies(); _categories = BuildCategories(); _mockPieRepository = new MockPieRepository().MockGetAllPies(_pies); _mockCategoryRepository = new MockCategoryRepository().MockGetAllCategories(BuildCategories()); _sut = new PieController(_mockPieRepository.Object, _mockCategoryRepository.Object); }
public void Init() { ClearCanvas(); matrixOfPoints = CombinedOldAndNewData(); KernalPca.Train(matrixOfPoints); kpcaMatrix = KernalPca.Transform(matrixOfPoints); Normalize.Initiate(matrixOfPoints); normalizedMatrix = Normalize.Matrix(matrixOfPoints); //targets = CombinedOldAndNewTargets(); numberOfPoints = matrixOfPoints.Length; GameObject pieInitiator = GameObject.Find("DataInitiator"); pieInitiatorScript = (PieController)pieInitiator.GetComponent(typeof(PieController)); var oldPies = CreatePies(ValfriStatic.MatrixOfPoints, ValfriStatic.Targets); var addedPies = new List <GameObject>(); try { addedPies = CreatePies(ValfriStatic.AddedPoints.GetRange(0, ValfriStatic.AddedPoints.Count - 1)); addedPies.AddRange(CreatePies(ValfriStatic.AddedPoints.GetRange(ValfriStatic.AddedPoints.Count - 1, 1), true)); } catch (System.Exception) { } oldPies.AddRange(addedPies); DipslayPies(oldPies); var knnPoints = new List <GameObject>(); try { for (int i = 0; i < Dataset.K; i++) { knnPoints.Add(oldPies[Knn.info[i].idx]); } } catch (System.Exception) { } foreach (var pie in knnPoints) { var pieScript = (BigPie)pie.GetComponent(typeof(BigPie)); pieScript.CreateBigPie(); } }