예제 #1
0
        public void DeepClone_NullValue_ReturnNull()
        {
            string?value  = null;
            var    result = CopyUtils.DeepClone(value);

            Assert.Equal(value, result);
        }
예제 #2
0
        public void DeepClone_Conference_ReturnEqualCopy()
        {
            var data = new Conference("123")
            {
                ConferenceId  = "test",
                Version       = 45,
                Configuration = { Moderators = new List <string> {
                                      "ghrd"
                                  }, ScheduleCron= "asd" },
            };

            var result = CopyUtils.DeepClone(data);

            Assert.Equal(JsonConvert.SerializeObject(data), JsonConvert.SerializeObject(result));
        }
예제 #3
0
        public async Task <Conference?> FindById(string conferenceId)
        {
            var key    = GetConferenceKey(conferenceId);
            var result = await _memoryCache.GetOrCreateAsync(key, async entry =>
            {
                entry.SetSlidingExpiration(TimeSpan.FromMinutes(1));
                return(await _conferenceRepo.FindById(conferenceId));
            });

            if (result == null)
            {
                return(null);
            }
            return(CopyUtils.DeepClone(result)); // important as we cache the conference and the object is mutable
        }