Beispiel #1
0
        static ApiCoreTestBase()
        {
            //now we support Tls only, and .net defaults to TLS
            //System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;

            var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);

            Logger.error(String.Format("Configuration file used: {0}, Exists:{1}", config.FilePath, config.HasFile));

            //getPropertyFromNames get the value from properties file or environment
            ApiLoginIdKey  = UnitTestData.GetPropertyFromNames(AuthorizeNet.Util.Constants.EnvApiLoginid, AuthorizeNet.Util.Constants.PropApiLoginid);
            TransactionKey = UnitTestData.GetPropertyFromNames(AuthorizeNet.Util.Constants.EnvTransactionKey, AuthorizeNet.Util.Constants.PropTransactionKey);
            _md5HashKey    = UnitTestData.GetPropertyFromNames(AuthorizeNet.Util.Constants.EnvMd5Hashkey, AuthorizeNet.Util.Constants.PropMd5Hashkey);

            //require only one cnp or cp merchant keys
            if (null != ApiLoginIdKey && null != TransactionKey)
            {
                Logger.debug("Merchant Login and transaction keys are present.");
            }
            else
            {
                throw new ArgumentException(
                          "LoginId and/or TransactionKey have not been set. Merchant keys are required.");
            }

            ErrorMessages = new Dictionary <string, string>();
        }
 public void AddUnitTestQuery(UnitTestData unitTestData, TimeSpan elapsed, bool isJenkins)
 {
     AddUnitTestQuery(_unitTestEntityUtil, unitTestData, elapsed);
     if (isJenkins)
     {
         AddUnitTestQuery(_unitTestEntityUtilJenkins, unitTestData, elapsed);
     }
 }
        private IUnit BuildUnit(UnitTestData unitData)
        {
            var mockUnit = new Mock <IUnit>();

            mockUnit.Setup(unit => unit.Type).Returns(unitData.Type);
            mockUnit.Setup(unit => unit.IsWounded).Returns(unitData.IsWounded);

            return(mockUnit.Object);
        }
        private IUnitTemplate BuildUnit(UnitTestData unitData)
        {
            var mockUnit = new Mock <IUnitTemplate>();

            mockUnit.Setup(unit => unit.Type).Returns(unitData.Type);
            mockUnit.Setup(unit => unit.name).Returns(unitData.Name);

            return(mockUnit.Object);
        }
 public void Setup()
 {
     _options = SqliteInMemory.CreateOptions <EfCoreContext>();
     using (var context = new EfCoreContext(_options))
     {
         context.Database.EnsureCreated();
         context.SeedDatabaseFourBooks();
         _utData = context.SetupSingleDtoAndEntities <AddReviewDto>();
     }
 }
 private MSTestResult CreateMSTestResult(XElement unitTest, XElement unitTestResult)
 {
     UnitTestData unitTestData = new UnitTestData();
     unitTestData.Name = unitTest.GetSafeAttributeValue(ns + "TestMethod", "name");
     unitTestData.Owner = GetOwner(unitTest);
     unitTestData.Description = GetDescription(unitTest);
     unitTestData.Suits = (from testCategory in unitTest.Descendants(ns + "TestCategoryItem")
         select testCategory.GetSafeAttributeValue("TestCategory")).ToList<string>();
     
     return CreateMSTestResultInternal(unitTestData, unitTestResult);
 }
Beispiel #7
0
        public void AddUnitTestQuery(UnitTestData unitTestData, TimeSpan elapsed, bool isJenkins)
        {
            var entity = _unitTestEntityUtil.GetEntity(isJenkins);

            entity.AssemblyCount++;
            entity.TestsPassed    += unitTestData.Passed;
            entity.TestsFailed    += unitTestData.Failed;
            entity.TestsSkipped   += unitTestData.Skipped;
            entity.ElapsedSeconds += (long)elapsed.TotalSeconds;
            _unitTestEntityUtil.Update(entity);
        }
        private IUnit BuildUnit(UnitTestData unitData, List <IImprovementTemplate> availableTemplates, out Mock <IUnit> mockUnit)
        {
            mockUnit = new Mock <IUnit>();
            var newUnit = mockUnit.Object;

            var unitLocation = BuildCell(unitData.Location, availableTemplates);

            MockUnitPositionCanon.Setup(canon => canon.GetOwnerOfPossession(newUnit)).Returns(unitLocation);

            return(newUnit);
        }
Beispiel #9
0
        private MSTestResult CreateMSTestResult(XElement unitTest, XElement unitTestResult)
        {
            UnitTestData unitTestData = new UnitTestData();

            unitTestData.Name        = unitTest.GetSafeAttributeValue(ns + "TestMethod", "name");
            unitTestData.Owner       = GetOwner(unitTest);
            unitTestData.Description = GetDescription(unitTest);
            unitTestData.Suits       = (from testCategory in unitTest.Descendants(ns + "TestCategoryItem")
                                        select testCategory.GetSafeAttributeValue("TestCategory")).ToList <string>();

            return(CreateMSTestResultInternal(unitTestData, unitTestResult));
        }
Beispiel #10
0
 public void Setup()
 {
     _options = SqliteInMemory.CreateOptions <EfCoreContext>();
     using (var context = new EfCoreContext(_options))
     {
         context.Database.EnsureCreated();
         if (!context.Books.Any())
         {
             context.SeedDatabaseFourBooks();
         }
         _utData = context.SetupSingleDtoAndEntities <Tests.Dtos.ChangePubDateDto>();
     }
 }
Beispiel #11
0
        public void Setup()
        {
            var con = this.GetUniqueDatabaseConnectionString(nameof(PerfListMany));

            _options = new DbContextOptionsBuilder <EfCoreContext>().UseSqlServer(con).Options;
            using (var context = new EfCoreContext(_options))
            {
                context.Database.EnsureCreated();
                if (!context.Books.Any())
                {
                    context.SeedDatabaseDummyBooks(100);
                }
                _utData = context.SetupSingleDtoAndEntities <BookListDto>();
            }
        }
Beispiel #12
0
        private IUnit BuildUnit(UnitTestData data)
        {
            var mockUnit = new Mock <IUnit>();

            mockUnit.Setup(unit => unit.CombatSummary).Returns(data.CombatSummary);

            var newUnit = mockUnit.Object;

            var owner = BuildCivilization(data.Owner);

            MockUnitPossessionCanon.Setup(canon => canon.GetOwnerOfPossession(newUnit)).Returns(owner);

            MockFortificationLogic.Setup(logic => logic.GetFortificationModifierForUnit(newUnit)).Returns(data.FortificationModifier);

            return(newUnit);
        }
Beispiel #13
0
        private IUnit BuildUnit(UnitTestData unitData, IHexCell location)
        {
            var mockUnit = new Mock <IUnit>();

            mockUnit.SetupAllProperties();

            mockUnit.Setup(unit => unit.CombatSummary).Returns(unitData.CombatSummary);

            var newUnit = mockUnit.Object;

            newUnit.CurrentMovement = unitData.CurrentMovement;

            MockUnitPositionCanon.Setup(canon => canon.GetOwnerOfPossession(newUnit)).Returns(location);

            return(newUnit);
        }
        public void SampleCodeCreateCustomerProfileFromTransaction()
        {
            LogHelper.info(Logger, "Sample createCustomerProfileFromTransaction");
            //var createRequest = new createCustomerProfileFromTransactionRequest();

            //ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
            //ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;

            //setup transaction to use
            var transactionId = GetTransactionId();
            //createRequest.refId = "11111111"; //request.RequestId;
            //createRequest.transId = transactionId.ToString(CultureInfo.InvariantCulture); // "60038686958"; // request.TransactionCode;
            //createRequest.merchantAuthentication = CustomMerchantAuthenticationType;
            var apiRequest = new APICore.createCustomerProfileFromTransactionRequest();

            apiRequest.refId = "11111111"; // request.RequestId;
            apiRequest.merchantAuthentication = new APICore.merchantAuthenticationType
            {
                name            = UnitTestData.GetPropertyFromNames(AuthorizeNet.Util.Constants.EnvApiLoginid, AuthorizeNet.Util.Constants.PropApiLoginid),
                ItemElementName = APICore.ItemChoiceType.transactionKey,
                Item            = UnitTestData.GetPropertyFromNames(AuthorizeNet.Util.Constants.EnvTransactionKey, AuthorizeNet.Util.Constants.PropTransactionKey),
            };
            apiRequest.transId = transactionId.ToString();
            AuthorizeNet.Environment environment = AuthorizeNet.Environment.SANDBOX;
            var transactionRequest = new CreateCustomerProfilePaymentFromTransaction();
            var createResponse     = (APICore.createCustomerProfileResponse)transactionRequest.CreateProfileFromTransaction(TestEnvironment, apiRequest);

            //validate
            Assert.NotNull(createResponse);
            Assert.NotNull(createResponse.messages);
            Assert.AreEqual(messageTypeEnum.Ok, createResponse.messages.resultCode);
            Assert.NotNull(createResponse.customerProfileId);
            Assert.NotNull(createResponse.customerPaymentProfileIdList);
            Assert.AreNotEqual(0, createResponse.customerPaymentProfileIdList.Length);

            long customerProfileId;

            long.TryParse(createResponse.customerProfileId, out customerProfileId);
            Assert.AreNotEqual(0, customerProfileId);

            long customerPaymentProfileId;

            long.TryParse(createResponse.customerPaymentProfileIdList[0], out customerPaymentProfileId);
            Assert.AreNotEqual(0, customerPaymentProfileId);
            //if shipping profile is added, shipping profile id will be retrieved too
        }
Beispiel #15
0
 public LimitDataForUnitTest GetUnitTestData(Guid unitTestId)
 {
     lock (_lockObject)
     {
         var result = UnitTestData.FirstOrDefault(t => t.UnitTestId == unitTestId);
         if (result == null)
         {
             result = new LimitDataForUnitTest()
             {
                 Id         = Guid.NewGuid(),
                 LimitData  = this,
                 UnitTestId = unitTestId
             };
             UnitTestData.Add(result);
         }
         return(result);
     }
 }
Beispiel #16
0
        private IUnit BuildUnit(UnitTestData unitData)
        {
            var mockUnit = new Mock <IUnit>();

            mockUnit.SetupAllProperties();

            mockUnit.Setup(unit => unit.Type).Returns(unitData.Type);

            var newUnit = mockUnit.Object;

            newUnit.Level            = unitData.Level;
            newUnit.CurrentHitpoints = unitData.Hitpoints;

            MockExperienceGainModifier.Setup(modifier => modifier.GetValueForUnit(newUnit))
            .Returns(unitData.ExperienceGainModifier);

            return(newUnit);
        }
Beispiel #17
0
        private IUnit BuildUnit(UnitTestData testData, IHexCell location, ICivilization owningCiv)
        {
            var mockUnit = new Mock <IUnit>();

            mockUnit.SetupAllProperties();

            mockUnit.Setup(unit => unit.Type).Returns(testData.Type);
            mockUnit.Setup(unit => unit.MaxHitpoints).Returns(testData.MaxHitpoints);
            mockUnit.Setup(unit => unit.CurrentMovement).Returns(testData.CurrentMovement);
            mockUnit.Setup(unit => unit.MaxMovement).Returns(testData.MaxMovement);

            var newUnit = mockUnit.Object;

            MockUnitPositionCanon.Setup(canon => canon.GetOwnerOfPossession(newUnit)).Returns(location);
            MockUnitPossessionCanon.Setup(canon => canon.GetOwnerOfPossession(newUnit)).Returns(owningCiv);

            MockPromotionParser.Setup(parser => parser.GetHealingInfo(newUnit)).Returns(testData.HealingInfo);

            return(newUnit);
        }
        static ApiCoreTestBase()
        {
            //getPropertyFromNames get the value from properties file or environment
            CnpApiLoginIdKey  = UnitTestData.GetPropertyFromNames(Constants.ENV_API_LOGINID, Constants.PROP_API_LOGINID);
            CnpTransactionKey = UnitTestData.GetPropertyFromNames(Constants.ENV_TRANSACTION_KEY, Constants.PROP_TRANSACTION_KEY);
            _cnpMd5HashKey    = null;
            CpApiLoginIdKey   = UnitTestData.GetPropertyFromNames(Constants.ENV_CP_API_LOGINID, Constants.PROP_CP_API_LOGINID);
            CpTransactionKey  = UnitTestData.GetPropertyFromNames(Constants.ENV_CP_TRANSACTION_KEY, Constants.PROP_CP_TRANSACTION_KEY);
            _cpMd5HashKey     = UnitTestData.GetPropertyFromNames(Constants.ENV_MD5_HASHKEY, Constants.PROP_MD5_HASHKEY);

            if ((null == CnpApiLoginIdKey) ||
                (null == CnpTransactionKey) ||
                (null == CpApiLoginIdKey) ||
                (null == CpTransactionKey))
            {
                throw new ArgumentException("LoginId and/or TransactionKey have not been set.");
            }

            _cnpMerchant = Merchant.CreateMerchant(TestEnvironment, CnpApiLoginIdKey, CnpTransactionKey);
            _cpMerchant  = Merchant.CreateMerchant(TestEnvironment, CpApiLoginIdKey, CpTransactionKey);

            ErrorMessages = new Dictionary <string, string>();
        }
Beispiel #19
0
        private MSTestResult CreateMSTestResultInternal(UnitTestData unitTestData, XElement unitTestResult)
        {
            string dataRowInfo = unitTestResult.GetSafeAttributeValue("dataRowInfo");

            // in data driven tests this appends the input row number to the test name
            string unitTestName = unitTestData.Name;

            unitTestName += dataRowInfo;

            TestOutcome outcome = (TestOutcome)Enum.Parse(typeof(TestOutcome), unitTestResult.Attribute("outcome").Value);

            DateTime start = DateTime.Parse(unitTestResult.Attribute("startTime").Value);

            DateTime end = DateTime.Parse(unitTestResult.Attribute("endTime").Value);

            /*
             * if (categories.Length == 0)
             *  categories = new string[]{ DEFAULT_CATEGORY };
             */

            IEnumerable <MSTestResult> innerTestResults = ParseInnerTestResults(unitTestData, unitTestResult);

            MSTestResult testResult = new MSTestResult(unitTestName, outcome, start, end, unitTestData.Suits, innerTestResults);

            bool containsInnerTestResults = unitTestResult.Element(ns + "InnerResults") == null;

            if ((outcome == TestOutcome.Error || outcome == TestOutcome.Failed) && containsInnerTestResults)
            {
                testResult.ErrorInfo = ParseErrorInfo(unitTestResult);
            }

            testResult.Owner = unitTestData.Owner;

            testResult.Description = unitTestData.Description;

            return(testResult);
        }
Beispiel #20
0
        private IEnumerable <MSTestResult> ParseInnerTestResults(UnitTestData unitTestData, XElement unitTestResult)
        {
            IEnumerable <XElement> innerResultsElements = unitTestResult.Descendants(ns + "InnerResults");

            if (!innerResultsElements.Any())
            {
                return(null);
            }

            // the schema for the trx states there can be multiple 'InnerResults' elements but
            // until we see it we take the first.
            // In the future if it will be required to handle multiple 'InnerResults' elements
            // one can wrap the comming loop in another loop that loops over them.
            XElement innerResultsElement = innerResultsElements.FirstOrDefault <XElement>();

            IList <MSTestResult> result = new List <MSTestResult>();

            foreach (XElement innerUnitTestResult in innerResultsElement.Descendants(ns + "UnitTestResult"))
            {
                result.Add(CreateMSTestResultInternal(unitTestData, innerUnitTestResult));
            }

            return(result);
        }
 private static void AddUnitTestQuery(CounterUtil <UnitTestCounterEntity> util, UnitTestData unitTestData, TimeSpan elapsed)
 {
     util.Update(entity =>
     {
         entity.AssemblyCount++;
         entity.TestsPassed    += unitTestData.Passed;
         entity.TestsFailed    += unitTestData.Failed;
         entity.TestsSkipped   += unitTestData.Skipped;
         entity.ElapsedSeconds += (long)elapsed.TotalSeconds;
     });
 }
        private IEnumerable<MSTestResult> ParseInnerTestResults(UnitTestData unitTestData, XElement unitTestResult)
        {
            IEnumerable<XElement> innerResultsElements = unitTestResult.Descendants(ns + "InnerResults");

            if (!innerResultsElements.Any())
                return null;

            // the schema for the trx states there can be multiple 'InnerResults' elements but
            // until we see it we take the first.
            // In the future if it will be required to handle multiple 'InnerResults' elements 
            // one can wrap the comming loop in another loop that loops over them.
            XElement innerResultsElement = innerResultsElements.FirstOrDefault<XElement>();

            IList<MSTestResult> result = new List<MSTestResult>();

            foreach (XElement innerUnitTestResult in innerResultsElement.Descendants(ns + "UnitTestResult"))
            {
                    result.Add(CreateMSTestResultInternal(unitTestData, innerUnitTestResult));
            }

            return result;
        }
        private MSTestResult CreateMSTestResultInternal(UnitTestData unitTestData, XElement unitTestResult)
        {
            string dataRowInfo = unitTestResult.GetSafeAttributeValue("dataRowInfo");

            // in data driven tests this appends the input row number to the test name
            string unitTestName = unitTestData.Name;
            
            unitTestName += dataRowInfo;

            TestOutcome outcome = (TestOutcome)Enum.Parse(typeof(TestOutcome), unitTestResult.Attribute("outcome").Value);

            DateTime start = DateTime.Parse(unitTestResult.Attribute("startTime").Value);

            DateTime end = DateTime.Parse(unitTestResult.Attribute("endTime").Value);

            /*
            if (categories.Length == 0)
                categories = new string[]{ DEFAULT_CATEGORY };
            */

            IEnumerable<MSTestResult> innerTestResults = ParseInnerTestResults(unitTestData, unitTestResult);

            MSTestResult testResult = new MSTestResult(unitTestName, outcome, start, end, unitTestData.Suits, innerTestResults);

            bool containsInnerTestResults = unitTestResult.Element(ns + "InnerResults") == null;
            if ((outcome == TestOutcome.Error || outcome == TestOutcome.Failed) && containsInnerTestResults)
            {
                testResult.ErrorInfo = ParseErrorInfo(unitTestResult);
            }

            testResult.Owner = unitTestData.Owner;

            testResult.Description = unitTestData.Description;
            
            return testResult;
        }
        private IUnit BuildUnit(UnitTestData unitData, List <IImprovementTemplate> availableTemplates)
        {
            Mock <IUnit> mock;

            return(BuildUnit(unitData, availableTemplates, out mock));
        }