예제 #1
0
        public void GetTicketCustomFields(int ticketId)
        {
            var apiMethod = string.Format("/Tickets/TicketCustomField/{0}", ticketId);

            this.kayakoApiRequest.Setup(x => x.ExecuteGet <TicketCustomFields>(apiMethod)).Returns(this.responseTicketCustomFields);

            var ticketCustomFields = this.ticketController.GetTicketCustomFields(ticketId);

            this.kayakoApiRequest.Verify(x => x.ExecuteGet <TicketCustomFields>(apiMethod), Times.Once());
            AssertUtility.ObjectsEqual(ticketCustomFields, this.responseTicketCustomFields);
        }
예제 #2
0
        public void GetCustomFieldListOptions(int customFieldId)
        {
            var apiMethod = string.Format("/Base/CustomField/ListOptions/{0}", customFieldId);

            this.kayakoApiRequest.Setup(x => x.ExecuteGet <CustomFieldOptionCollection>(apiMethod)).Returns(this.responseCustomFieldOptionsCollection);

            var customFieldOptions = this.customFieldController.GetCustomFieldOptions(customFieldId);

            this.kayakoApiRequest.Verify(x => x.ExecuteGet <CustomFieldOptionCollection>(apiMethod), Times.Once());
            AssertUtility.ObjectsEqual(customFieldOptions, this.responseCustomFieldOptionsCollection);
        }
예제 #3
0
        public void Write_ArgumentValidation()
        {
            var adapter = new UdpClientAdapter(new UdpClient());

            // buffer
            AssertUtility.Throws <ArgumentNullException>(() => adapter.Write(null, 1, 1));

            // offset
            AssertUtility.Throws <ArgumentOutOfRangeException>(() => adapter.Write(new byte[2], -1, 2));
            AssertUtility.Throws <ArgumentOutOfRangeException>(() => adapter.Write(new byte[2], 3, 3));
        }
예제 #4
0
        public void Divide(float val)
        {
            AssertUtility.Assert(val > 0);

            _keysList.Clear();
            _keysList.AddRange(_dataSet.Keys);
            foreach (var key in _keysList)
            {
                _dataSet[key] = _dataSet[key] / val;
            }
        }
예제 #5
0
        public void GetCustomFields()
        {
            const string apiMethod = "/Base/CustomField";

            this.kayakoApiRequest.Setup(x => x.ExecuteGet <CustomFieldCollection>(apiMethod)).Returns(this.responseCustomFieldCollection);

            var customFields = this.customFieldController.GetCustomFields();

            this.kayakoApiRequest.Verify(x => x.ExecuteGet <CustomFieldCollection>(apiMethod), Times.Once());
            AssertUtility.ObjectsEqual(customFields, this.responseCustomFieldCollection);
        }
예제 #6
0
        public override void Run(out bool result)
        {
            result = true;

            result &=
                // Check count
                AssertUtility.Expect(loadoutInstance.Count, 0, string.Format(StringResource.ObjectCount, nameof(loadoutInstance)))
                &&
                AssertUtility.Expect(loadoutInstance.CachedList.Count, 0, string.Format(StringResource.ObjectCount, nameof(loadoutInstance.CachedList)))
            ;
        }
예제 #7
0
 public WeaponBagContainer this[int bagIndex]
 {
     get
     {
         AssertUtility.Assert(bagIndex < WeaponBags.Count);
         if (bagIndex < 0)
         {
             bagIndex = HeldBagPointer;
         }
         return(WeaponBags[bagIndex]);
     }
 }
예제 #8
0
        public void UpdateTicketCustomField(int ticketId)
        {
            var          apiMethod  = string.Format("/Tickets/TicketCustomField/{0}", ticketId);
            const string parameters = "FieldName1=content1&FieldName2=content2";

            this.kayakoApiRequest.Setup(x => x.ExecutePost <TicketCustomFields>(apiMethod, parameters)).Returns(this.responseTicketCustomFields);

            var ticketCustomFields = this.ticketController.UpdateTicketCustomFields(ticketId, this.responseTicketCustomFields);

            this.kayakoApiRequest.Verify(x => x.ExecutePost <TicketCustomFields>(apiMethod, parameters), Times.Once());
            AssertUtility.ObjectsEqual(ticketCustomFields, this.responseTicketCustomFields);
        }
예제 #9
0
        public LoginWindow()
        {
            InitializeComponent();


            ConfigurationService = Activator.ConfigurationService;
            AssertUtility.NotNull(ConfigurationService);

            LoadSetting();

            Content = new LoginUserControl();
        }
예제 #10
0
        public IGameEntity GetGameEntity(EntityKey entityKey)
        {
            var info = infos[entityKey.EntityType];

            if (info == null)
            {
                AssertUtility.Assert(false, "infos[" + entityKey.EntityType + "] == null");
                return(null);
            }

            return(info.GetEntity(entityKey));
        }
 public static void RestoreCollider(GameObject gameObject, List <bool> restoreValue)
 {
     _colliderList.Clear();
     gameObject.GetComponentsInChildren <Collider>(_colliderList);
     AssertUtility.Assert(restoreValue.Count == _colliderList.Count);
     for (int i = 0; i < restoreValue.Count; ++i)
     {
         _colliderList[i].enabled = restoreValue[i];
     }
     _colliderList.Clear();
     restoreValue.Clear();
 }
예제 #12
0
        public static string Content(IBundle bundle, string url)
        {
            AssertUtility.ArgumentNotNull(bundle, "bundle");
            AssertUtility.ArgumentHasText(url, "url");

            while (url.StartsWith("~") || url.StartsWith("/") || url.StartsWith("\\"))
            {
                url = url.Remove(0, 1);
            }

            return(Path.Combine(bundle.Location.Replace(_webRootPath, @"~\"), url));
        }
예제 #13
0
 public List <IAssemblyMetadataNode> AttachFragment(IFragmentBundleMetadataNode fragment)
 {
     AssertUtility.ArgumentNotNull(fragment, "fragement");
     if (!this.FragmentNodes.Contains(fragment))
     {
         fragment.HostNode = this;
         base.ConstraintResolver.ResolvedAssemblyMetadataNodes.AddRange(fragment.SharedAssemblyNodes);
         base.ConstraintResolver.ResolvedAssemblyMetadataNodes.AddRange(fragment.PrivateAssemblyNodes);
         this.FragmentNodes.Add(fragment);
         this.SortByBundleID <IFragmentBundleMetadataNode>(this.FragmentNodes, true);
     }
     return(null);
 }
예제 #14
0
        public void DeSerialize(BinaryReader reader, INetworkObjectSerializerManager serializerManager)
        {
            BaseSnapshotSeq = reader.ReadInt32();
            AssertUtility.Assert(_entityPatchList.Count == 0);
            var count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                AbstractEntityPatch patch = CreateEntityPatch((EntityReplicateOperationType)reader.ReadByte());
                patch.DeSerialize(reader, serializerManager);
                _entityPatchList.Add(patch);
            }
        }
예제 #15
0
        public void Write(MyBinaryWriter writer)
        {
            AssertUtility.Assert((int)EEventType.End < 255);
            int c = _events.Count;

            writer.Write((short)c);
            for (var i = 0; i < c; i++)
            {
                var node = _events[i];
                writer.Write((byte)node.EventType);
                node.WriteBody(writer);
            }
        }
예제 #16
0
        public static PlayerEntity GetPlayerFromChildCollider(Collider collider)
        {
            var transform = collider.transform;

            while (transform.parent != null && transform.GetComponent <CharacterController>() == null)
            {
                transform = transform.parent.transform;
            }

            AssertUtility.Assert(transform.GetComponent <CharacterController>() != null);

            return((PlayerEntity)transform.gameObject.GetComponent <EntityReference>().Reference);
        }
예제 #17
0
        public void AddContextInfo(IGameContext basicInfo)
        {
            AddEntities(basicInfo);
            AssertUtility.Assert(!_infos.ContainsKey(basicInfo.EntityType));
            IEntitasGameContext nec = (IEntitasGameContext)basicInfo;

            foreach (var context in _infos.Values)
            {
                IEntitasGameContext ec = (IEntitasGameContext)context;
                AssertUtility.Assert(ec.ComponentTypes != nec.ComponentTypes);
                AssertUtility.Assert(ec.EntitasContext != nec.EntitasContext);
            }
            _infos[basicInfo.EntityType] = basicInfo;
        }
예제 #18
0
        public void Read(BinaryReader reader)
        {
            AssertUtility.Assert((int)EEventType.End < 255);

            int count = reader.ReadByte();

            for (int i = 0; i < count; i++)
            {
                var type = (EEventType)reader.ReadByte();
                var v    = EventInfos.Instance.Allocate(type, true);
                v.ReadBody(reader);
                _events.Add(v.EventType, v);
            }
        }
예제 #19
0
        public void ReadWriteMultipleRegisters()
        {
            var mockSerialResource = MockRepository.GenerateStub <IStreamResource>();
            var master             = ModbusSerialMaster.CreateRtu(mockSerialResource);

            // validate numberOfPointsToRead
            AssertUtility.Throws <ArgumentException>(() => master.ReadWriteMultipleRegisters(1, 1, 0, 1, new ushort[] { 1 }));
            AssertUtility.Throws <ArgumentException>(() => master.ReadWriteMultipleRegisters(1, 1, 126, 1, new ushort[] { 1 }));

            // validate writeData
            AssertUtility.Throws <ArgumentNullException>(() => master.ReadWriteMultipleRegisters(1, 1, 1, 1, null));
            AssertUtility.Throws <ArgumentException>(() => master.ReadWriteMultipleRegisters(1, 1, 1, 1, new ushort[] { }));
            AssertUtility.Throws <ArgumentException>(() => master.ReadWriteMultipleRegisters(1, 1, 1, 1, Enumerable.Repeat <ushort>(1, 122).ToArray()));
        }
예제 #20
0
 private void AcquireReference_Internal(bool isCheck)
 {
     SetCurrentThread();
     if (isCheck)
     {
         AssertUtility.Assert(Interlocked.Increment(ref _refCount) != 1);
     }
     else
     {
         Interlocked.Increment(ref _refCount);
     }
     AssertUtility.Assert(_refCount < MaxRef);
     ClearCurrentThread();
 }
예제 #21
0
        private void CheckVehicleCmdList(List <IVehicleCmd> cmdList)
        {
            if (_lastSeq < 0)
            {
                _lastSeq      = cmdList[0].CmdSeq;
                _lastRecvTime = DateTime.Now;
                _frameRateInv = 1000 / Application.targetFrameRate + 16 + 5;

                return;
            }

            if (_logger.IsDebugEnabled)
            {
                AssertUtility.Assert(cmdList.Count > 0);
                var  expectedSeq = _lastSeq + 1;
                bool found       = false;
                foreach (var cmd in cmdList)
                {
                    if (cmd.CmdSeq == expectedSeq)
                    {
                        found = true;
                    }

                    if (cmd.CmdSeq > _lastSeq)
                    {
                        _lastSeq = cmd.CmdSeq;
                    }
                }

                if (!found)
                {
                    _logger.InfoFormat("ServerSync Lost Cmd Seq {0}", expectedSeq);
                }
            }

            if (_logger.IsInfoEnabled)
            {
                var curTime = DateTime.Now;

                var deltaTime = curTime - _lastRecvTime;

                if (deltaTime.TotalMilliseconds > _frameRateInv)
                {
                    _logger.InfoFormat("The delta time of received vehicle cmd  is too large {0}, seq {1}", deltaTime.TotalMilliseconds, cmdList[0].CmdSeq);
                }

                _lastRecvTime = curTime;
            }
        }
예제 #22
0
        public MainWindow()
        {
            InitializeComponent();

            var navigationServiceFactory = BundleActivator.NavigationServiceFactoryTracker.DefaultOrFirstService;

            _systemMenuNavigationService = navigationServiceFactory.CreateNavigationService(SystemMenuExtensionPoint);
            _configurationService        = BundleActivator.ConfigurationServiceTracker.DefaultOrFirstService;
            AssertUtility.NotNull(_configurationService);
            AssertUtility.NotNull(_systemMenuNavigationService);

            Closing += (sender, e) => SaveSettings();

            LoadSettings();
        }
예제 #23
0
#pragma warning disable RefCounter002
        public bool TryGetGameEntity(EntityKey entityKey, out IGameEntity entity)
#pragma warning restore RefCounter002
        {
            entity = null;

            var info = infos[entityKey.EntityType];

            if (info == null)
            {
                AssertUtility.Assert(false, "infos[" + entityKey.EntityType + "] == null");
                return(false);
            }

            return(info.TryGetEntity(entityKey, out entity));
        }
        public int Compare(IThrowingSegment x, IThrowingSegment y)
        {
            AssertUtility.Assert(y != null, "y != null");
            AssertUtility.Assert(x != null, "x != null");

            if (x.ServerTime == y.ServerTime)
            {
                return(0);
            }
            if (x.ServerTime < y.ServerTime)
            {
                return(-1);
            }
            return(1);
        }
예제 #25
0
        public bool IsWheelBrokeByIndex(VehiclePartIndex index, out VehicleUiWheelIndex uiIndex)
        {
            AssertUtility.Assert(IsOnVehicle);

            uiIndex = VehicleUiWheelIndex.None;
            var vehicle = GetCurrentVehicle();

            if (vehicle != null && vehicle.IsCar())
            {
                uiIndex = WheelEntityUtility.GetUiWheelIndex(vehicle, index);
                return(vehicle.vehicleBrokenFlag.IsVehiclePartBroken(index));
            }

            return(false);
        }
예제 #26
0
        public void Write(MyBinaryWriter writer)
        {
            AssertUtility.Assert((int)EEventType.End < 255);

            writer.Write((byte)_events.Count);
            foreach (KeyValuePair <EEventType, List <IEvent> > eventListPair in _events)
            {
                writer.Write((byte)eventListPair.Key);
                writer.Write(eventListPair.Value.Count);
                foreach (var node in eventListPair.Value)
                {
                    node.WriteBody(writer);
                }
            }
        }
예제 #27
0
        public int Compare(DefaultBulletSegment x, DefaultBulletSegment y)
        {
            AssertUtility.Assert(y != null, "y != null");
            AssertUtility.Assert(x != null, "x != null");

            if (x.ServerTime == y.ServerTime)
            {
                return(0);
            }
            if (x.ServerTime < y.ServerTime)
            {
                return(-1);
            }
            return(1);
        }
예제 #28
0
        public LoginUserControl()
        {
            InitializeComponent();
            PermissionService = Activator.PermissionService;
            AssertUtility.NotNull(PermissionService, "PermissionService is not registered.");

            // 从配置文件中获取已经登录的用户
            var loginUsers = Activator.ConfigurationService.Get(Activator.Bundle, "LoginUsers", string.Empty);

            if (!string.IsNullOrEmpty(loginUsers))
            {
                var users = loginUsers.Split(';').Reverse().ToArray(); // 最新登录的放最后
                UserComboBox.ItemsSource  = users;
                UserComboBox.SelectedItem = users[0];                  // 选择第一项
            }
        }
예제 #29
0
 public BundleContext(AbstractBundle bundle)
 {
     AssertUtility.ArgumentNotNull(bundle, "BundleContext.bundle");
     Bundle    = bundle;
     Framework = bundle.Framework;
     AssertUtility.ArgumentNotNull(Framework, "Framework");
     ExtensionManager = GetFirstOrDefaultService <IExtensionManager>();
     AssertUtility.ArgumentNotNull(ExtensionManager, "ExtensionManager");
     ExtensionManager.ExtensionChanged      += new EventHandler <ExtensionEventArgs>(OnExtensionChanged);
     ExtensionManager.ExtensionPointChanged += new EventHandler <ExtensionPointEventArgs>(OnExtensionPointChanged);
     Framework.EventManager.AddFrameworkEventListener(new EventHandler <FrameworkEventArgs>(OnFrameworkStateChanged));
     Framework.EventManager.AddBundleEventListener(new EventHandler <BundleStateChangedEventArgs>(OnBundleStateChanged), false);
     Framework.EventManager.AddBundleEventListener(new EventHandler <BundleStateChangedEventArgs>(OnSyncBundleStateChanged), true);
     Framework.EventManager.AddServiceEventListener(new EventHandler <ServiceEventArgs>(OnServiceChanged));
     Framework.EventManager.AddBundleLazyActivatedEventListener(new EventHandler <BundleLazyActivatedEventArgs>(OnBundleLazyActivated));
 }
예제 #30
0
        private void AssignAnimatorParameters(List <NetworkAnimatorParameter> paramsList)
        {
            AssertUtility.Assert(AnimatorParameters.Count == paramsList.Count);
            int count = AnimatorParameters.Count;

            for (int i = 0; i < count; i++)
            {
                var oldParam = AnimatorParameters[i];
                var newParam = paramsList[i];
                //减少函数调用,by zwl
                oldParam.ParamType  = newParam.ParamType;
                oldParam.IntValue   = newParam.IntValue;
                oldParam.FloatValue = newParam.FloatValue;
                oldParam.BoolValue  = newParam.BoolValue;
                oldParam.NameHash   = newParam.NameHash;
            }
        }