public void Get_All_API()
        {
            //Arrange
            typeServiceMock.Setup(x => x.GetAll()).Returns(items);

            //Act
            var actionResult  = controllerAPI.Get();
            var createdResult = actionResult as OkNegotiatedContentResult <IEnumerable <Type> >;

            //Assert
            Assert.IsNotNull(createdResult);
            Assert.IsInstanceOfType(createdResult.Content, typeof(IEnumerable <Type>));
            Assert.AreEqual(items, createdResult.Content);
        }
        public void TypesControllerGetAllTest()
        {
            var topic      = CreateContext();
            var Logic      = CreateLogic();
            var Controller = new TypesController(Logic);
            var FirstType  = new TypeEntity()
            {
                Id      = Guid.NewGuid(),
                Name    = "First Type",
                Topic   = topic,
                TopicId = topic.Id
            };

            var SecondType = new TypeEntity
            {
                Id      = Guid.NewGuid(),
                Name    = "Second Type",
                Topic   = topic,
                TopicId = topic.Id
            };

            Logic.Create(FirstType);
            Logic.Create(SecondType);

            List <TypeEntity> Types = new List <TypeEntity>()
            {
                FirstType, SecondType
            };

            var Result        = Controller.Get();
            var CreatedResult = Result as OkObjectResult;
            var TypeResults   = CreatedResult.Value as IEnumerable <TypeDTO>;

            Assert.AreEqual(Types.Count, TypeResults.ToList().Count);
        }
Esempio n. 3
0
        public async Task Get_WhenCalled_Should_Return_OkResult()
        {
            // Arrange
            _mediator.Send(Arg.Any <IRequest <IEnumerable <TypeOutputModel> > >()).Returns(new List <TypeOutputModel>());

            // Act
            var result = await _sut.Get();

            // Assert
            result.Should().BeOfType <OkObjectResult>();
        }
Esempio n. 4
0
        public void ReturnsEventTypes()
        {
            var result = _typesController.Get();

            Assert.IsInstanceOfType(result, typeof(OkObjectResult));

            var objectResult = (result as OkObjectResult)?.Value;
            var eventTypes   = objectResult as List <EventType>;

            Assert.IsTrue(eventTypes != null);
            Assert.AreEqual(eventTypes.Count, 2);
            Assert.IsTrue(!string.IsNullOrEmpty(eventTypes[0].Name));
        }
        public void TypesControllerGetTest()
        {
            var topic      = CreateContext();
            var Logic      = CreateLogic();
            var Controller = new TypesController(Logic);
            var Type       = new TypeEntity
            {
                Id      = Guid.NewGuid(),
                Name    = "First Type",
                Topic   = topic,
                TopicId = topic.Id
            };

            Logic.Create(Type);

            var Result        = Controller.Get(Type.Id);
            var CreatedResult = Result as OkObjectResult;
            var Model         = CreatedResult.Value as TypeDTO;

            Assert.AreEqual(Type.Name, Model.Name);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            //test
            TypesController typesController = new TypesController();

            typesController.Add(new Types {
                TypesId = 1, TypesName = "Товар"
            });
            typesController.Add(new Types {
                TypesId = 2, TypesName = "Услуга"
            });
            typesController.Add(new Types {
                TypesId = 3, TypesName = "Набор"
            });
            typesController.Add(new Types {
                TypesId = 4, TypesName = "Комплект"
            });



            SpeciesController speciesController = new SpeciesController();

            speciesController.Add(new Species {
                SpeciesId = 1, SpeciesName = "Продукты", Types = typesController.Get(1)
            });
            speciesController.Add(new Species {
                SpeciesId = 2, SpeciesName = "МБП", Types = typesController.Get(1)
            });
            speciesController.Add(new Species {
                SpeciesId = 3, SpeciesName = "МНМА", Types = typesController.Get(1)
            });
            speciesController.Add(new Species {
                SpeciesId = 4, SpeciesName = "Набор", Types = typesController.Get(1)
            });
            speciesController.Add(new Species {
                SpeciesId = 5, SpeciesName = "Оборудование", Types = typesController.Get(1)
            });
            speciesController.Add(new Species {
                SpeciesId = 6, SpeciesName = "Полуфабрикат", Types = typesController.Get(1)
            });
            speciesController.Add(new Species {
                SpeciesId = 7, SpeciesName = "Продукция", Types = typesController.Get(1)
            });
            speciesController.Add(new Species {
                SpeciesId = 8, SpeciesName = "Комплект", Types = typesController.Get(4)
            });
            speciesController.Add(new Species {
                SpeciesId = 9, SpeciesName = "Услуга", Types = typesController.Get(2)
            });


            ProductsController productsController = new ProductsController();

            Product product = new Product {
                ProductId = 1, ProductName = "Картошка", ProductUnit = decimal.Parse("100,6"), Species = speciesController.Get(1)
            };

            productsController.Add(product);
            Product product1 = new Product {
                ProductId = 2, ProductName = "Запчасть до авто", ProductUnit = decimal.Parse("100,69"), Species = speciesController.Get(2)
            };

            productsController.Add(product1);
            Product product2 = new Product {
                ProductId = 3, ProductName = "Золотое кольцо", ProductUnit = decimal.Parse("100,69896"), Species = speciesController.Get(3)
            };

            productsController.Add(product2);

            foreach (var prod in productsController.GetAll())
            {
                prod.Display();
            }



            Console.ReadKey();
        }