public async void Patch_No_Errors()
        {
            AddressControllerMockFacade mock = new AddressControllerMockFacade();
            var mockResult = new Mock <UpdateResponse <ApiAddressResponseModel> >();

            mockResult.SetupGet(x => x.Success).Returns(true);
            mock.ServiceMock.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <ApiAddressRequestModel>()))
            .Callback <int, ApiAddressRequestModel>(
                (id, model) => model.AddressLine1.Should().Be("A")
                )
            .Returns(Task.FromResult <UpdateResponse <ApiAddressResponseModel> >(mockResult.Object));
            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiAddressResponseModel>(new ApiAddressResponseModel()));
            AddressController controller = new AddressController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiAddressModelMapper());

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var patch = new JsonPatchDocument <ApiAddressRequestModel>();

            patch.Replace(x => x.AddressLine1, "A");

            IActionResult response = await controller.Patch(default(int), patch);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            mock.ServiceMock.Verify(x => x.Update(It.IsAny <int>(), It.IsAny <ApiAddressRequestModel>()));
        }
        public async Task ShouldCheckOutPersons()
        {
            var addressRepository   = Substitute.For <IRepository <Address, Guid> >();
            var addressDataProvider = Substitute.For <IAddressDataProvider>();
            var addressFactory      = new AddressFactory();

            var addressEntity = addressFactory.Create(new AddressFactoryInput()
            {
                City = "test", Street = "test", HomeNumber = "test", StreetNumber = "test", Id = Guid.NewGuid()
            });

            addressEntity.CheckInPersons(6);

            addressRepository.Get(addressEntity.Id).Returns(addressEntity);

            AddressController addressController = new AddressController(addressRepository, addressDataProvider, addressFactory, Substitute.For <IMeterReadDataProvider>());

            await
            addressController.CheckOutPerson(new CheckOut()
            {
                AddressId = addressEntity.Id,
                Persons   = 5
            });


            await addressRepository.Received(1).Get(addressEntity.Id);

            Assert.Equal(1, addressEntity.CheckedInPersons);
        }
        public void GetAllAddresses()
        {
            var mock = new Mock <IRepository <Address> >();

            mock.Setup(repo => repo.GetAll()).Returns(GetAllTest());
            var factoryMock = new Mock <IRepositoryFactory>();

            factoryMock.Setup(f => f.GetRepository <Address>()).Returns(mock.Object);
            var serviceMock = new Mock <ICleaningServiceServiceFactory>();

            factoryMock.Setup(f => f.GetRepository <Address>()).Returns(mock.Object);
            _addressController = new AddressController(serviceMock.Object, factoryMock.Object);

            var json    = _addressController.GetAll();
            var address = json.Value as List <Address>;

            Assert.NotNull(json);
            Assert.NotNull(address);
            Assert.AreEqual(address.Count, 2);

            //var mock1 = new Mock<IRepository<Address>>();
            //mock1.Setup(repo => repo.GetAll().FirstOrDefault()).Returns(GetFirstOrDefaultTest(1));
            //var factoryMock1 = new Mock<IRepositoryFactory>();
            //factoryMock1.Setup(f => f.GetRepository<Address>()).Returns(mock1.Object);
            //_addressController = new AddressController(factoryMock1.Object);

            //json = _addressController.GetAll();
            //address = json.Value as List<Address>;
            //Assert.AreEqual();
        }
Exemple #4
0
        public void DeleteAddressBadRequestFailureTest()
        {
            int    id              = 1;
            string Address1        = "Test";
            string Address2        = "Test";
            string City            = "Test";
            string ZipCode         = "Test";
            bool   isDeleted       = false;
            int    AddressTypeId   = 1;
            int    CreatedByUserId = 1;

            NSI.REST.Models.AddressCreateModel address = new AddressCreateModel()
            {
                AddressId       = id,
                Address1        = Address1,
                Address2        = Address2,
                City            = City,
                ZipCode         = ZipCode,
                AddressTypeId   = AddressTypeId,
                CreatedByUserId = CreatedByUserId,
                IsDeleted       = isDeleted,
                DateCreated     = DateTime.Now,
                DateModified    = DateTime.Now
            };

            var addressRepo = new Mock <IAddressRepository>();

            addressRepo.Setup(x => x.DeleteAddressById(It.IsAny <int>())).Throws <Exception>();
            var addressManipulation = new AddressManipulation(addressRepo.Object);
            var controller          = new AddressController(addressManipulation);
            var result = controller.DeleteAddress(1);

            Assert.IsType <BadRequestObjectResult>(result);
        }
        public void UpdateAddressNoContentFailureTest()
        {
            int    id              = 1;
            string Address1        = "Test";
            string Address2        = "Test";
            string City            = "Test";
            string ZipCode         = "Test";
            bool   isDeleted       = false;
            int    AddressTypeId   = 1;
            int    CreatedByUserId = 1;

            NSI.REST.Models.AddressEditModel address = new AddressEditModel()
            {
                Address1      = Address1,
                Address2      = Address2,
                City          = City,
                ZipCode       = ZipCode,
                IsDeleted     = isDeleted,
                AddressTypeId = AddressTypeId,
                DateModified  = DateTime.Now
            };

            var addressRepo = new Mock <IAddressRepository>();

            addressRepo.Setup(x => x.EditAddress(It.IsAny <int>(), It.IsAny <AddressDto>()));
            var addressManipulation = new AddressManipulation(addressRepo.Object);
            var controller          = new AddressController(addressManipulation);
            var result = controller.PutAddress(1, address);

            Assert.IsType <NoContentResult>(result);
        }
        public void TestAddressInfo_ReturningExceptionViewForNotNullSessionId()
        {
            Mock <HttpSessionStateBase> session = new Mock <HttpSessionStateBase>();

            session.Setup(s => s["studentAddressId"]).Returns(2);

            Mock <HttpContextBase> httpContext = new Mock <HttpContextBase>();

            httpContext.SetupGet(c => c.Session).Returns(session.Object);

            ControllerContext ctx = new ControllerContext();

            ctx.HttpContext = httpContext.Object;

            Mock <IStudentAddressBusinessAccess> mock = new Mock <IStudentAddressBusinessAccess>();
            Exception exception = new Exception();

            mock.Setup(x => x.DisplayStudentAddressInfoByIdFromDatabase(2)).Throws(exception);

            AddressController addressController = new AddressController(mock.Object);

            addressController.ControllerContext = ctx;

            ViewResult result = addressController.AddressInfo() as ViewResult;

            Assert.That(result.ViewName, Is.EqualTo("Error"));
        }
        public void CreateNewAddressNoContentFailureTest()
        {
            int      id              = 1;
            string   Address1        = "Test";
            string   Address2        = "Test";
            string   City            = "Test";
            string   ZipCode         = "71000";
            bool     isDeleted       = false;
            int      AddressTypeId   = 1;
            int      CreatedByUserId = 1;
            DateTime DateCreated     = DateTime.Now;
            DateTime DateModified    = DateTime.Now;

            NSI.REST.Models.AddressCreateModel address = new AddressCreateModel()
            {
                Address1        = Address1,
                Address2        = Address2,
                City            = City,
                ZipCode         = ZipCode,
                AddressTypeId   = AddressTypeId,
                CreatedByUserId = CreatedByUserId,
                DateCreated     = DateCreated,
                DateModified    = DateModified
            };

            var mockRepo = new Mock <IAddressManipulation>();

            mockRepo.Setup(x => x.CreateAddress(It.IsAny <AddressDto>()));
            var controller = new AddressController(mockRepo.Object);
            var result     = controller.PostAddress(address);

            Assert.IsType <NoContentResult>(result);
        }
        public void TestPostAddressInfo_ReturningCorrectView_ForNotNullStudentId()
        {
            Mock <HttpSessionStateBase> session = new Mock <HttpSessionStateBase>();

            session.Setup(s => s["studentAddressId"]).Returns(1);

            Mock <HttpContextBase> httpContext = new Mock <HttpContextBase>();

            httpContext.SetupGet(c => c.Session).Returns(session.Object);

            ControllerContext ctx = new ControllerContext();

            ctx.HttpContext = httpContext.Object;

            Mock <IStudentAddressBusinessAccess> mock = new Mock <IStudentAddressBusinessAccess>();

            mock.Setup(x => x.UpdateStudentAddressInfoIntoDatabase(student));

            AddressController addressController = new AddressController(mock.Object);

            addressController.ControllerContext = ctx;

            RedirectToRouteResult result = addressController.AddressInfo(student) as RedirectToRouteResult;

            Assert.That(result.RouteValues["action"], Is.EqualTo("QualificationInfo"));
        }
        public async void BulkInsert_No_Errors()
        {
            AddressControllerMockFacade mock = new AddressControllerMockFacade();

            var mockResponse = new CreateResponse <ApiAddressResponseModel>(new FluentValidation.Results.ValidationResult());

            mockResponse.SetRecord(new ApiAddressResponseModel());
            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiAddressRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiAddressResponseModel> >(mockResponse));
            AddressController controller = new AddressController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var records = new List <ApiAddressRequestModel>();

            records.Add(new ApiAddressRequestModel());
            IActionResult response = await controller.BulkInsert(records);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var result = (response as OkObjectResult).Value as List <ApiAddressResponseModel>;

            result.Should().NotBeEmpty();
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiAddressRequestModel>()));
        }
 public void AddressControllerConstructorTest()
 {
     IFormsAuthentication formsAuthentication = null; // TODO: Initialize to an appropriate value
     IAddressService addressService = null; // TODO: Initialize to an appropriate value
     AddressController target = new AddressController(formsAuthentication, addressService);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public AddressControllerTest()
 {
     AddressServiceMock  = new Mock <IAddressService>();
     UserServiceMock     = new Mock <IUserService>();
     LoggerMock          = new Mock <ILogger <AddressController> >();
     LocalizerMock       = new Mock <ISharedResource>();
     ControllerUnderTest = new AddressController(AddressServiceMock.Object, UserServiceMock.Object, LoggerMock.Object, LocalizerMock.Object);
 }
        public void HomesController_GetPropertyUsingInvalidGuid_ReturnBadRequest()
        {
            AddressController addressController = new AddressController(_findAddress);
            var requestType = addressController.GetAddress(Guid.NewGuid());
            BadRequestObjectResult badRequest = (BadRequestObjectResult)requestType.Result;

            Assert.True(badRequest.StatusCode == 400);
        }
        public async Task Can_Redirect_When_No_Exisiting_Addresses()
        {
            AddressController     addressCtrl = new AddressController(addressRepo);
            RedirectToRouteResult result      = await addressCtrl.List("#111111") as RedirectToRouteResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("Add", result.RouteValues["action"]);
        }
        public async Task Can_Delete_Address()
        {
            AddressController     addressCtrl = new AddressController(addressRepo);
            RedirectToRouteResult result      = (RedirectToRouteResult)await addressCtrl.DeleteAddress(4);

            Assert.AreEqual("List", result.RouteValues["action"]);
            Assert.AreEqual("#421521", result.RouteValues["userId"]);
        }
    void Start()
    {
        // init utymap library
        _compositionRoot = InitTask.Run((container, config) =>
        {
            container
            .Register(Component.For <Stylesheet>().Use <Stylesheet>(@"mapcss/ground/ground.mapcss"))
            .Register(Component.For <MaterialProvider>().Use <MaterialProvider>())
            .Register(Component.For <GameObjectBuilder>().Use <GameObjectBuilder>())
            .Register(Component.For <IGeocoder>().Use <UtyMapGeocoder>())
            .Register(Component.For <IElementBuilder>().Use <PlaceElementBuilder>().Named("place"));
        });

        // initial geo position and quad key of character
        var coordinate = new GeoCoordinate(StartLatitude, StartLongitude);
        var quadKey    = GeoUtils.CreateQuadKey(coordinate, LevelOfDetail);

        // init address controller which is responsible for searching address
        _addressController = new AddressController(
            _compositionRoot.GetService <IGeocoder>(),
            Text.GetComponent <Text>());

        // init tile controller which is responsible for tile processing
        _tileController = new TileController(
            _compositionRoot.GetService <IMapDataStore>(),
            _compositionRoot.GetService <Stylesheet>(),
            ElevationType,
            coordinate,
            LevelOfDetail);

        // freeze target till initial tile is loaded
        var rigidbody = CharacterTarget.transform.GetComponent <Rigidbody>();

        rigidbody.isKinematic = true;
        // TODO unsubscribe listener
        _compositionRoot
        .GetService <IMapDataStore>()
        .ObserveOn <Tile>(Scheduler.MainThread)
        .Subscribe(tile =>
        {
            if (!quadKey.Equals(tile.QuadKey))
            {
                return;
            }

            // get elevation at current position
            var elevation = _compositionRoot
                            .GetService <IMapDataLibrary>()
                            .GetElevation(ElevationType, quadKey, coordinate);
            // move character accordingly
            CharacterTarget.transform.localPosition = new Vector3(
                CharacterTarget.transform.localPosition.x,
                (float)elevation + 5f,
                CharacterTarget.transform.localPosition.z);
            rigidbody.isKinematic = false;
        });
    }
Exemple #16
0
        public void Get_InvalidAddress_ReturnsError()
        {
            var addressController = new AddressController();
            var expectedResult    = "Address has no outputs to spend or is invalid.\n";

            var result = addressController.Get("1Aff4FgrtA1dZDwajmknWTwU2WtwUvfiXa");

            Assert.AreEqual(result, expectedResult);
        }
Exemple #17
0
        public void SetUp()
        {
            _addressServiceMock = new Mock <IAddressService>();
            _addressServiceMock.Setup(x => x.GetAddress()).ReturnsAsync(GetAddress);
            _groupViewModelBuilderMock = new Mock <ICityGroupViewModelBuilder>();
            _groupViewModelBuilderMock.Setup(x => x.Build(It.IsAny <string>(), It.IsAny <IEnumerable <Address> >())).Returns(GetCityGroupViewModel);

            addressController = new AddressController(_addressServiceMock.Object, _groupViewModelBuilderMock.Object);
        }
        public void Address_Controller_Put_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    AddressController addressController = new AddressController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(addressController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, addressController.DatabaseType);

                    Address addressLast = new Address();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        AddressService addressService = new AddressService(query, db, ContactID);
                        addressLast = (from c in db.Addresses select c).FirstOrDefault();
                    }

                    // ok with Address info
                    IHttpActionResult jsonRet = addressController.GetAddressWithID(addressLast.AddressID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <Address> Ret = jsonRet as OkNegotiatedContentResult <Address>;
                    Address addressRet = Ret.Content;
                    Assert.AreEqual(addressLast.AddressID, addressRet.AddressID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Put to return success
                    IHttpActionResult jsonRet2 = addressController.Put(addressRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <Address> addressRet2 = jsonRet2 as OkNegotiatedContentResult <Address>;
                    Assert.IsNotNull(addressRet2);

                    BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest2);

                    // Put to return CSSPError because AddressID of 0 does not exist
                    addressRet.AddressID = 0;
                    IHttpActionResult jsonRet3 = addressController.Put(addressRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <Address> addressRet3 = jsonRet3 as OkNegotiatedContentResult <Address>;
                    Assert.IsNull(addressRet3);

                    BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult;
                    Assert.IsNotNull(badRequest3);
                }
            }
        }
Exemple #19
0
        public async Task GetAsync_ShouldReturnNotFoundGivenNoAddress()
        {
            this._addressService.Setup(x => x.GetAsync(It.IsAny <int>())).ReturnsAsync(default(Address));
            var controller = new AddressController(this._addressService.Object);

            var actionResult = await controller.GetAsync(It.IsAny <int>());

            actionResult.Result.Should().BeOfType <NotFoundResult>();
        }
        public void AddressController_GetAddressUsingGuid_ReturnAddreessFirstLive()
        {
            AddressController addressController = new AddressController(_findAddress);
            var            requestType          = addressController.GetAddress(Guid.Parse("e3944055-9df7-4ad7-b36a-84bcd00ee1b4"));
            OkObjectResult okRequest            = requestType.Result as OkObjectResult;
            IAddress       result = (IAddress)okRequest.Value;

            Assert.NotNull(result);
        }
        public void UpdateAddressFailureTest()
        {
            var mockRepo   = new Mock <IAddressManipulation>();
            var controller = new AddressController(mockRepo.Object);

            controller.ModelState.AddModelError("error", "some error");
            var result = controller.PutAddress(1, model: null);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Exemple #22
0
        public void ReturnProperView_WhenIvokedWithId()
        {
            var cityServiceMock    = new Mock <ICityService>();
            var addressServiceMock = new Mock <IAddressService>();

            var controller = new AddressController(cityServiceMock.Object, addressServiceMock.Object);
            var result     = controller.CreateAddressByCompanyId(1) as ViewResult;

            Assert.AreEqual("Create", result.ViewName);
        }
        public AddressControllerTests()
        {
            //Create
            _transactionLibraryInternal = Substitute.For <TransactionLibraryInternal>(null, null, null, null, null, null, null, null, null, null, null);
            _countries  = new List <Country>();
            _controller = new AddressController(_transactionLibraryInternal, _countries.AsQueryable());

            _controller.Url = Substitute.For <UrlHelper>();
            _controller.Url.Action(Arg.Any <string>()).Returns("ControllerUrl");
        }
        public void ReturnProperView()
        {
            var cityServiceMock    = new Mock <ICityService>();
            var addressServiceMock = new Mock <IAddressService>();

            var controller = new AddressController(cityServiceMock.Object, addressServiceMock.Object);
            var result     = controller.GetAddressesByCompanyId(1) as ViewResult;

            Assert.AreEqual("Index", result.ViewName);
        }
        public void TestPostAddressInfo_WhenModelStateIsInvalid()
        {
            AddressController addressController = new AddressController();

            addressController.ModelState.AddModelError("xyz", "Error has occured");

            ViewResult result = addressController.AddressInfo(student2) as ViewResult;

            Assert.That(result.ViewName, Is.EqualTo("AddressInfo"));
        }
Exemple #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AddressUC"/> class.
        /// </summary>
        /// <param name="theGrid">The grid.</param>
        public AddressUC(DataGridView theGrid)
        {
            UserControlType = UserControls.Address;
            DataGrid        = theGrid;

            this.InitializeComponent();

            this.theController = new AddressController();

            this.loadAddresses();
        }
        public void GetAddressesByIdTest()
        {
            // Arrange
            AddressController controller = new AddressController();

            // Act
            var result = controller.GetAddress(5);

            // Assert
            Assert.IsNotNull(result);
        }
Exemple #28
0
 public void Test1()
 {
     try
     {
         AddressController addressController = new AddressController();
         addressController.AllEstates();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public void GetNotFoundAddress()
        {
            var options = TestDbContext.TestDbInitalizer("TestingGetNotFoundAddressControllerConstructor");

            using (var database = TestDbContext.CreateTestDb(options))
            {
                _AC = new AddressController();
                _AC._addressHelper = Api.Helpers.AddressHelper.ChangeRepository(database);
                var result = _AC.Get();
                Assert.IsType <NotFoundObjectResult>(result);
            }
        }
        public void Test_InsertAddressAndReturnOk()
        {
            var   _logger = Mock.Of <ILogger <AddressController> >();
            Datas data    = new Datas();

            _userRepository.Setup(r => r.AddAddress(data.SetAddressForTest));
            _controller = new AddressController(_logger, _userRepository.Object);

            IActionResult result = _controller.AddAddress(data.SetAddressForTest);

            Assert.IsType <OkObjectResult>(result);
        }
        public void Test_ReturnOk_WhenAddressFound()
        {
            var   _logger = Mock.Of <ILogger <AddressController> >();
            Datas datas   = new Datas();

            _userRepository.Setup(r => r.GetAddressesByUser("vThushy")).Returns(datas.SetListOfAddressForTest);
            _controller = new AddressController(_logger, _userRepository.Object);

            IActionResult result = _controller.GetAllAddressByCustomer("vThushy");

            Assert.IsType <OkObjectResult>(result);
        }
Exemple #32
0
        protected void cmdDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Null.IsNull(_nav.AddressID))
                {
                    AddressController controller = new AddressController();
                    controller.DeleteAddress(int.Parse(_nav.AddressID));

                    _nav.AddressID = Null.NullString;
                }

                invokeEditComplete();
            }
            catch(Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        public void ShouldBeAbleToRemoveDeliveryAddress()
        {
            // arrange
            var controller = new AddressController(this.formsAuthentication, this.addressService);
            const int AddressIdToRemove = 1;

            // act
            var actual = controller.Remove(AddressIdToRemove) as JsonNetResult;

            // assert
            Assert.That(actual, Is.Not.Null);
            Debug.Assert(actual != null, "actual != null");
            var model = actual.Data as DeliveryAddressViewModel;
            Debug.Assert(model != null, "model != null");
            Assert.That(model.MessageType, Is.EqualTo("Success"));
            Assert.That(model.Id, Is.EqualTo(1));
        }
 public void AddTest()
 {
     IFormsAuthentication formsAuthentication = null; // TODO: Initialize to an appropriate value
     IAddressService addressService = null; // TODO: Initialize to an appropriate value
     AddressController target = new AddressController(formsAuthentication, addressService); // TODO: Initialize to an appropriate value
     DeliveryAddressDetails view = null; // TODO: Initialize to an appropriate value
     JsonResult expected = null; // TODO: Initialize to an appropriate value
     JsonResult actual;
     actual = target.Add(view);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
        public void ShouldBeAbleToUpdateDeliveryAddress()
        {
            // arrange
            var controller = new AddressController(this.formsAuthentication, this.addressService);
            var viewModel = new DeliveryAddressViewModel
            {
                Id = 1,
                AddressName = "Test 1",
                AddressLine1 = "street",
                AddressLine2 = "flat",
                City = "Minsk",
                CountryCode = "BY",
                Region = null,
                State = null,
                FirstName = "Vitali",
                LastName = "Hatalski",
                Phone = null,
                ZipCode = "1233",
                AddressLine3 = null
            };

            // act
            var actual = controller.Update(viewModel) as JsonNetResult;

            // assert
            Assert.That(actual, Is.Not.Null);
            Debug.Assert(actual != null, "actual != null");
            var model = actual.Data as DeliveryAddressViewModel;
            Debug.Assert(model != null, "model != null");
            Assert.That(model.MessageType, Is.EqualTo("Success"));
            Assert.That(model.Id, Is.EqualTo(1));
            Assert.That(model.AddressName, Is.EqualTo("Test 1"));
            Assert.That(model.AddressLine1, Is.EqualTo("street"));
            Assert.That(model.AddressLine2, Is.EqualTo("flat"));
            Assert.That(model.AddressLine3, Is.Null);
            Assert.That(model.City, Is.EqualTo("Minsk"));
            Assert.That(model.CountryCode, Is.EqualTo("BY"));
            Assert.That(model.Region, Is.Null);
            Assert.That(model.State, Is.Null);
            Assert.That(model.FirstName, Is.EqualTo("Vitali"));
            Assert.That(model.LastName, Is.EqualTo("Hatalski"));
            Assert.That(model.Phone, Is.Null);
            Assert.That(model.ZipCode, Is.EqualTo("1233"));
        }
        public void ShouldReturnJsonCollectionOfUserAddresses()
        {
            // arrange
            var controller = new AddressController(this.formsAuthentication, this.addressService);

            // act
            var actual = controller.Get() as JsonNetResult;

            // assert
            Assert.That(actual, Is.Not.Null);
            Debug.Assert(actual != null, "actual != null");
            var model = actual.Data as List<DeliveryAddressViewModel>;
            Debug.Assert(model != null, "model != null");
            Assert.That(model.Count, Is.GreaterThan(0));
        }
Exemple #37
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // Get the navigation settings
                _nav = new CustomerNavigation(Request.QueryString);

                if (!Null.IsNull(dataSource))
                {
                    _addressID = (int)dataSource;
                    _nav.AddressID = _addressID.ToString();
                }
                else
                {
                    _addressID = int.Parse(_nav.AddressID);
                }

                if (!Page.IsPostBack)
                {
                    // Load country & region lists
                    loadCountryList();
                    loadRegionList();

                    // Set delete confirmation
                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");

                    // Are we editing or creating new item?
                    if (!Null.IsNull(_addressID))
                    {
                        AddressController controller = new AddressController();
                        AddressInfo address = controller.GetAddress(_addressID);

                        if (address != null)
                        {
                            cmdDelete.Visible = true;

                            txtDescription.Text = address.Description;
                            txtName.Text = address.Name;
                            txtAddress1.Text = address.Address1;
                            txtAddress2.Text = address.Address2;
                            txtCity.Text = address.City;
                            cboCountry.SelectedValue = address.CountryCode;
                            cboRegion.SelectedValue = address.RegionCode;
                            txtPostalCode.Text = address.PostalCode;
                            txtPhone1.Text = address.Phone1;
                            txtPhone2.Text = address.Phone2;
                            chkPrimary.Checked = address.PrimaryAddress;
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Exemple #38
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true)
                {
                    PortalSecurity security = new PortalSecurity();

                    AddressInfo address = new AddressInfo();

                    address.AddressID = _addressID;
                    address.PortalID = this.PortalId;
                    address.UserID = this.UserId;
                    address.Description = security.InputFilter(txtDescription.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Name = security.InputFilter(txtName.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Address1 = security.InputFilter(txtAddress1.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Address2 = security.InputFilter(txtAddress2.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.City = security.InputFilter(txtCity.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.CountryCode = cboCountry.SelectedValue;
                    address.RegionCode = cboRegion.SelectedValue;
                    address.PostalCode = security.InputFilter(txtPostalCode.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Phone1 = security.InputFilter(txtPhone1.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Phone2 = security.InputFilter(txtPhone2.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.PrimaryAddress = chkPrimary.Checked;
                    address.CreatedByUser = this.UserId.ToString();
                    address.CreatedDate	= DateTime.Now;

                    AddressController controller = new AddressController();

                    if (Null.IsNull(address.AddressID) || address.AddressID == 0)
                    {
                        controller.AddAddress(address);
                    }
                    else
                    {
                        controller.UpdateAddress(address);
                    }

                    invokeEditComplete();
                }
            }
            catch(Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }