Ejemplo n.º 1
0
        public void SalespersonControllerTest_GetAll()
        {
            SalespersonController controller = new SalespersonController();

            var people = controller.Get();

            Assert.AreNotEqual(0, people.ToList().Count);
        }
Ejemplo n.º 2
0
        public void GetSalespersonNotFoundTest()
        {
            //Arrange
            var controller = new SalespersonController();
            //Act
            IHttpActionResult result = controller.GetSalesperson(100);

            //Assert
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Ejemplo n.º 3
0
        public void SalespersonControllerTest_Get()
        {
            SalespersonController controller = new SalespersonController();

            var person = controller.Get(1);

            const string name = "Mike";

            Assert.AreEqual(name, person.Name);
        }
Ejemplo n.º 4
0
        public SalespeopleView()
        {
            InitializeComponent();
            obsPeople    = new ObservableCollection <Salesperson>();
            editedPeople = new ObservableCollection <Salesperson>();
            controller   = new SalespersonController();

            obsPeople.CollectionChanged   += ObsPeople_CollectionChanged;
            DataGrid.CellEditEnding       += DataGrid_CellEditEnding;
            DataGrid.SelectedCellsChanged += DataGrid_SelectedCellsChanged;
            this.Loaded += SalespeopleView_Loaded;
        }
Ejemplo n.º 5
0
        public void GetSalespersonByIdTest()
        {
            //Arrange
            var controller = new SalespersonController();
            //Act
            IHttpActionResult result = controller.GetSalesperson(1);
            var contentResult        = result as OkNegotiatedContentResult <Salesperson>;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(1, contentResult.Content.Id);
        }
Ejemplo n.º 6
0
        public void GetAllSalespersonsTest()
        {
            //Arrange
            var controller = new SalespersonController();
            //Act
            IHttpActionResult result = controller.GetAllSalespersons();
            var contentResult        = result as OkNegotiatedContentResult <List <Salesperson> >;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(10, contentResult.Content.Count);
        }
Ejemplo n.º 7
0
        public void UpdateDistrictTest()
        {
            //Arrange
            var controller      = new SalespersonController();
            var testSalesperson = new Salesperson {
                Id = 10, Name = "Test Updated"
            };
            //Act
            IHttpActionResult result = controller.PutSalesperson(testSalesperson);
            var contentResult        = result as NegotiatedContentResult <Salesperson>;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.AreEqual(HttpStatusCode.Accepted, contentResult.StatusCode);
            Assert.IsNotNull(contentResult.Content);
        }
        public DistrictsView()
        {
            InitializeComponent();

            districtContext    = new DistrictController();
            salespersonContext = new SalespersonController();
            editedDistricts    = new ObservableCollection <District>();

            this.Loaded += DistrictsView_Loaded;
            DataGrid.SelectedCellsChanged += DataGrid_SelectedCellsChanged;
            DataGrid.CellEditEnding       += DataGrid_CellEditEnding;
            SecondarySalespersonDataGrid.SelectedCellsChanged += SecondarySalespersonDataGrid_SelectedCellsChanged;
            PrimarySalespersonNewComboBox.DropDownClosed      += PrimarySalespersonNewComboBox_DropDownClosed;
            ReassignPrimarySalespersonComboBox.DropDownClosed += ReassignPrimarySalespersonComboBox_DropDownClosed;
            SecondarySalespersonComboBox.DropDownClosed       += SecondarySalespersonComboBox_DropDownClosed;
        }
Ejemplo n.º 9
0
        public void SalespersonControllerTest_POST_DELETE()
        {
            SalespersonController controller = new SalespersonController();

            var person = new Salesperson()
            {
                Id       = 0,
                Name     = "Controller",
                LastName = "Test"
            };

            controller.Post(person);

            person = controller.Get().ToList().SingleOrDefault(x => { return(x.Name.Equals(person.Name) && x.LastName.Equals(person.LastName)); });

            controller.Delete(person.Id);
        }
Ejemplo n.º 10
0
        private async Task <IEnumerable <Salesperson> > LoadPeople()
        {
            SalespersonController controller = new SalespersonController();
            var people = await controller.GetAllAsync();

            var converted = new List <Salesperson>();

            foreach (var person in people.ToList())
            {
                converted.Add(new Salesperson()
                {
                    Id       = person.Id,
                    Name     = person.Name,
                    LastName = person.LastName
                });
            }
            return(converted);
        }
Ejemplo n.º 11
0
        public void SalespersonControllerTest_PUT()
        {
            SalespersonController controller = new SalespersonController();

            var person = controller.Get(3);

            string nameOld = person.Name;
            string nameNew = "Watson";

            person.Name = nameNew;

            controller.Put(person.Id, person);
            person = null;

            person = controller.Get(3);

            Assert.AreEqual(nameNew, person.Name);

            person.Name = nameOld;
            controller.Put(person.Id, person);
        }
Ejemplo n.º 12
0
        public static SalespersonController Fixture()
        {
            SalespersonController controller = new SalespersonController(new SalespersonRepository(), "", new LoginView());

            return(controller);
        }
 public ShellViewModel()
 {
     api          = new SalespersonController();
     api.Endpoint = "http://localhost:50209/";
 }
 public SalespersonControllerTest()
 {
     controller          = new SalespersonController();
     controller.Endpoint = "http://localhost:50209/";
 }
Ejemplo n.º 15
0
 public static SalespersonController Fixture()
 {
     SalespersonController controller = new SalespersonController(new SalespersonRepository(), "", new LoginView());
     return controller;
 }
 public SalespersonControllerTest()
 {
     controller = new SalespersonController();
 }