Пример #1
0
        public void Can_Create_Delete_Account()
        {
            var servicePackages    = _lookupService.GetServicePackages();
            var contactTypes       = _lookupService.GetContactTypes().ToList();
            var contactMethods     = _lookupService.GetContactMethods().ToList();
            var paymentMethods     = _lookupService.GetPaymentMethods().ToList();
            var nvralertTypes      = _lookupService.GetNvrAlertTypes().ToList();
            var eventGroups        = _lookupService.GetEventGroups().ToList();
            var analyticAlgorithms = _lookupService.GetAnalyticAlgorithmTypes().ToList();


            //step 1 - create account
            var accountDto = new AccountDto
            {
                AccountNumber    = "123456789",
                Name             = "Test_Account",
                ServicePackageId = servicePackages.ToList().SingleOrDefault(sp => sp.Name == "Silver").ServicePackageId,
                WebSiteURL       = "http://2020Imaging.com",
                Email            = "*****@*****.**",
                Description      = "Test_Account_Description",
                TimeZoneId       = _lookupService.GetTimeZones().First().TimeZoneId,
                AccountTypeId    = _lookupService.GetAccountTypes().Single(at => at.AccoutTypeId == 2).AccoutTypeId,
                AccountBilling   = null,
            };

            var accountId = _accountService.AddAccount(accountDto);

            Assert.IsTrue(accountId > 0);

            var getAccount = _accountService.GetAccount(accountId);

            Assert.IsNotNull(getAccount);

            // step 2 - create person
            var personDto = new PersonDto
            {
                Title     = "Msr.",
                FirstName = "Victor",
                LastName  = "Lungu",
                JobTitle  = "WPF Developer",
                Password  = "******",
                PrimaryAccountAdministratorPassword = "******",
            };

            var preferedContact1 = new PersonContactTypeDto {
                ContactTypeId = contactTypes[0].ContactTypeId
            };
            var preferedContact2 = new PersonContactTypeDto {
                ContactTypeId = contactTypes[1].ContactTypeId
            };

            personDto.PreferedContactTypes = new List <PersonContactTypeDto> {
                preferedContact1, preferedContact2
            };
            var savedPerson = _accountService.SaveAccountPerson(personDto, getAccount.AccountId);

            Assert.IsNotNull(savedPerson);

            // step 3 - create contact
            var contactDto = new ContactDto
            {
                TelephoneNumber = "37379604494",
                EmailAddress    = "*****@*****.**",
                MobileNumber    = "37379604494",
                LyncName        = "Lync Name",
                FaxNumber       = "37379604494",
            };

            var preferedContatMethod1 = new PreferedContatMethodDto
            {
                ContactMethodId = contactMethods[0].ContactMethodId
            };

            var preferedContatMethod2 = new PreferedContatMethodDto
            {
                ContactMethodId = contactMethods[1].ContactMethodId
            };

            contactDto.PreferedContatMethods.Add(preferedContatMethod1);
            contactDto.PreferedContatMethods.Add(preferedContatMethod2);

            var savedContact = _accountService.SaveAccountContact(contactDto, savedPerson.PersonId);

            Assert.IsNotNull(savedContact);

            //step 4 - create accounnt address
            var addressDto = new AddressDto
            {
                AddressNumber   = 3343,
                AddressTypeCode = 22,
                City            = "Chisinau",
                Country         = "Moldova, Republic of",
                County          = "municipiiul Chisinau",
                Fax             = "37379604494",
                Latitude        = 100.22233,
                Line1           = "str. Iazului 6",
                Line2           = "ap. 53",
                Longitude       = 444332,
                Name            = "Main Address",
                PostOfficeBox   = "443332",
                PostalCode      = "PC5543"
            };

            var accountAddress = _accountService.SaveAccountAddress(addressDto, accountId);

            Assert.IsNotNull(accountAddress);

            //step 5 Billing address
            var billingAddress = new AddressDto
            {
                AddressNumber   = 3343,
                AddressTypeCode = 22,
                City            = "Chisinau",
                Country         = "Moldova, Republic of",
                County          = "municipiiul Chisinau",
                Fax             = "37379604494",
                Latitude        = 100.22233,
                Line1           = "str. Iazului 6",
                Line2           = "ap. 53",
                Longitude       = 444332,
                Name            = "Main Address",
                PostOfficeBox   = "443332",
                PostalCode      = "PC5543"
            };

            var accountBilling = new AccountBillingDto
            {
                PaymentMethodId = paymentMethods.First().PaymentMethodId,
                Address         = billingAddress
            };

            var accountBillig = _accountService.SaveAccountBilling(accountBilling, accountId);

            Assert.IsNotNull(accountBillig);

            var accountNvrAlertTypeDto1 = new AccountNvrAlertTypeDto
            {
                NvrAlertTypeId = nvralertTypes.First().NvrAlertTypeId
            };
            var accountNvrAlertTypeDto2 = new AccountNvrAlertTypeDto
            {
                NvrAlertTypeId = nvralertTypes.Last().NvrAlertTypeId
            };

            _accountService.SaveAccountNvrAlertType(
                new List <AccountNvrAlertTypeDto>()
            {
                accountNvrAlertTypeDto1, accountNvrAlertTypeDto2
            }, accountId);

            var accountAlarmPanel1 = new AccountAlarmPanelDto()
            {
                EventGroupId = eventGroups.First().EventGroupId
            };
            var accountAlarmPanel2 = new AccountAlarmPanelDto()
            {
                EventGroupId = eventGroups.Last().EventGroupId
            };

            _accountService.SaveAccountAlarmPanel(
                new List <AccountAlarmPanelDto>()
            {
                accountAlarmPanel1, accountAlarmPanel2
            }, accountId);

            var analyticAlgorithm1 = new AccountAnalyticsAlgorithmTypeDto()
            {
                AnalyticsAlgorithTypeId = analyticAlgorithms.First().AnalyticAlgorithmId
            };
            var analyticAlgorithm2 = new AccountAnalyticsAlgorithmTypeDto()
            {
                AnalyticsAlgorithTypeId = analyticAlgorithms.Last().AnalyticAlgorithmId
            };

            _accountService.SaveAccountAnalyticsAlgorithms(
                new List <AccountAnalyticsAlgorithmTypeDto>()
            {
                analyticAlgorithm1, analyticAlgorithm2
            }, accountId);

            var deleteContact = _accountService.DeleteContact(savedContact.ContactId);

            Assert.IsTrue(deleteContact);

            _accountService.DeletePerson(savedPerson.PersonId);
            var accountDeleted = _accountService.DeleteAccount(getAccount.AccountId);

            Assert.IsTrue(accountDeleted);
        }
Пример #2
0
        public void CanGetAccountTypes()
        {
            var accountTypes = _lookupServiceImpl.GetAccountTypes().ToList();

            Assert.IsTrue(accountTypes.Count > 0);
        }