public void SeedTableCountry()
 {
     countryService.AddCountry("Bulgaria");
     countryService.AddCountry("Germany");
     countryService.AddCountry("Greece");
     countryService.AddCountry("Serbia");
     countryService.AddCountry("France");
     countryService.AddCountry("Russia");
     countryService.AddCountry("Turkey");
     countryService.AddCountry("Hungary");
     countryService.AddCountry("Austria");
     countryService.AddCountry("Norway");
 }
        protected void BtnAddCountry_Click(object sender, EventArgs e)
        {
            var country = new Country();

            country.CountryName = CountryNamebox.Text.ToString().Trim();
            var countryService = new CountryService();
            int count          = countryService.ExperimentalCountry(country);

            if (String.IsNullOrWhiteSpace(country.CountryName))
            {
                Response.Write("<script>alert('还啥都没写呢')</script>");
            }
            else if (count <= 0)
            {
                var result = countryService.AddCountry(country);
                if (result == 1)
                {
                    Bind();
                    Response.Write("<script>alert('添加成功')</script>");
                }
                else
                {
                    Response.Write("<script>alert('添加失败!')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('已经存在此名字,换一个再试')</script>");
            }
        }
        public ApplicationCountryViewModel()
        {
            List <Country> collection = CountryService.GetCountries();

            foreach (Country c in collection)
            {
                Countries.Add(new CountryModel(c));
            }

            Countries.CollectionChanged += (s, e) =>
            {
                if (e.Action.ToString().Equals("Add"))
                {
                    CountryModel countryModel = null;
                    foreach (CountryModel cm in e.NewItems)
                    {
                        countryModel = cm;
                    }

                    CountryService.AddCountry(countryModel.Country);
                }
                else if (e.Action.ToString().Equals("Remove"))
                {
                    CountryModel countryModel = null;
                    foreach (CountryModel cm in e.OldItems)
                    {
                        countryModel = cm;
                    }

                    CountryService.RemoveCountry(countryModel.Country);
                }
                OnPropertyChanged("Countries");
            };
        }
Exemple #4
0
        private string AddCountry()
        {
            Console.Write("Enter country name: ");
            string name = Console.ReadLine();

            return(countryService.AddCountry(name));
        }
        public void CountryService_AddCountry_ShouldAddCountryToSession()
        {
            var country = new Country {
                Name = "UK", ISOTwoLetterCode = "GB"
            };

            _countryService.AddCountry(country);

            Session.QueryOver <Country>().List().Should().HaveCount(1);
        }
        public void TestAddingCountryWithNameNull()
        {
            var mockSet = new Mock <DbSet <Country> >();

            var mockContext = new Mock <TravelSimulatorContext>();

            mockContext.Setup(m => m.Countries).Returns(mockSet.Object);

            var countryService = new CountryService(mockContext.Object);

            string countryName = null;

            Assert.Throws <ArgumentException>(() => countryService.AddCountry(countryName));
        }
Exemple #7
0
        public void AddCountryTest()
        {
            //Arrange
            countryRepositoryMock.Setup(x => x.Insert(It.IsAny <Country>()))
            .Verifiable("should call Insert of GenericRepository!!!");
            unitOfWorkMock.Setup(x => x.Save())
            .Verifiable("should call save of UnitOfWork");

            var countryDto = new CountryDTO();

            //Act
            var countryDtoResult = countryService.AddCountry(countryDto);

            //Assert
            Assert.IsNotNull(countryDtoResult);
            unitOfWorkMock.Verify();
            countryRepositoryMock.Verify();
        }
Exemple #8
0
        public void AddCountry_Success_Test()
        {
            // Arrange
            CountryDTO dto = SampleCountryDTO(1);

            // create mock for repository
            var mock = new Mock <ICountryRepository>();

            mock.Setup(s => s.AddCountry(Moq.It.IsAny <R_Country>())).Returns(1);

            // service
            CountryService countryService = new CountryService();

            CountryService.Repository = mock.Object;

            // Act
            int id = countryService.AddCountry(dto);

            // Assert
            Assert.AreEqual(1, id);
            Assert.AreEqual(1, dto.CountryId);
        }
 public IEnumerable <Country> AddCountry(Country country)
 {
     return(countryService.AddCountry(country));
 }