public async Task ActivationInfoValueObject_Activate_Success() { await RunWithTelemetryAsync( totalOfExecutions : 1, runInParallel : false, handler : async execution => { #region Arrange var activationUser = "******"; var customer = new Customer(); #endregion #region Act customer.Activate(activationUser); #endregion #region Assert return(await Task.FromResult( customer.ActivationInfo.IsActive && customer.ActivationInfo.ActivationUser == activationUser && DateTime.UtcNow - customer.ActivationInfo.ActivationDate.GetValueOrDefault() <= TimeSpan.FromSeconds(3) ).ConfigureAwait(false)); #endregion } ); }
public async Task ActivableDomainModelSpecification_MustHaveActivationInfo_Success() { await RunWithTelemetryAsync( totalOfExecutions : 1, runInParallel : false, handler : async execution => { #region Arrange var activationUser = "******"; var customer = new Customer(); var customerMustBeActiveValidation = ServiceProvider.GetService <ICustomerMustBeActiveValidation>(); #endregion #region Act customer.Activate(activationUser); var validationResult = customerMustBeActiveValidation.Validate(customer) .ConfigureAwait(false) .GetAwaiter() .GetResult(); #endregion #region Assert return(await Task.FromResult(validationResult.IsValid).ConfigureAwait(false)); #endregion } ); }
public void clears_events() { var customer = new Customer(10); customer.Activate(); customer.GetUncommittedEvents().Should().HaveCount(1); }
public void keeps_events_in_the_list_of_uncommitted_changes() { var customer = new Customer(10); customer.Activate(); var expectedEvent = new CustomerActivated(10); customer.GetUncommittedEvents().Should().HaveCount(1); customer.GetUncommittedEvents() .First().Should().BeEquivalentTo(expectedEvent, a => a.Excluding(z => z.EventId).Excluding(z => z.PublishDateTime)); }
} = 240; //Thời gian kết thúc, sau sẽ được truyện vào từ Terminate //Method sinh Cus public IEnumerator <Task> Generator(Process p, object data) { Console.WriteLine(this.Now + @" The barber shop is opening for business..."); //Resource barbers = CreateBarbers(); ABarbers = Resource.Create(new List <Barber>() { new Barber(this, "Minh"), new Barber(this, "Anh") }); int i = 0; switch (TypeDistribuion) { case Distribution.NormalDis: TypeDis = new Normal(Interval, 1.0); break; case Distribution.ExponentialDis: TypeDis = new Exponential(Interval); break; default: Console.WriteLine("k tim thay"); break; } do { long d; do { d = (long)TypeDis.NextDouble(); } while (d <= 0L); if (FirstTime != 0 && Now == 0) { yield return(p.Delay(FirstTime)); i++; //Console.WriteLine(@"xxx so Cus trong hang doi = " + ABarbers.BlockCount + " " + Now); Customer c = new Customer(this, i.ToString(), this.Now, QueueCapacity); c.Activate(null, 0L, ABarbers); Console.WriteLine(this.Now + " The customer " + c.Name + " come"); } else { yield return(p.Delay(d)); Console.WriteLine(@"xxx BlockCount - " + ABarbers.BlockCount + "- OutOfService - " + ABarbers.OutOfService + "- Reserved - " + ABarbers.Reserved + "- Now - " + Now); i++; Customer c = new Customer(this, i.ToString(), this.Now, QueueCapacity); c.Activate(null, 0L, ABarbers); Console.WriteLine(this.Now + " The customer " + c.Name + " come"); Console.WriteLine(@"yyy BlockCount - " + ABarbers.BlockCount + "- OutOfService - " + ABarbers.OutOfService + "- Reserved - " + ABarbers.Reserved + "- Now - " + Now); //point = new Point(Now, ABarbers.BlockCount); Points.Add(new Point(Now, ABarbers.BlockCount)); } } while (Now < EndingTime && i < LengthOfFile); Console.WriteLine(@"======================================================"); Console.WriteLine(@"The barber shop is closed for the day."); if (ABarbers.BlockCount > 0) { Console.WriteLine(@"The barbers have to work late today."); } yield break; }