예제 #1
0
		public void Append_01 ()
		{
			// arrange:
			ISchedule schedule = new Schedule();
		
			// act:
			schedule.Append(null);
		}
예제 #2
0
		public void Ctor_01()
		{
			// arrange:
			
		
			// act:
			ISchedule schedule = new Schedule();
		
			// assert:
			Assert.AreEqual(0, schedule.Count());
			CollectionAssert.AreEqual(schedule, schedule.AsWeakEnumerable());
			Assert.AreEqual(0, schedule.MovementsCount);
		}
예제 #3
0
		public void Append_02()
		{
			// arrange:
			ICarrierMovement m1 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			ISchedule empty = new Schedule();
		
			// act:
			ISchedule schedule = empty.Append(m1);
		
			// assert:
			Assert.IsFalse(schedule.Equals(empty));
			Assert.IsTrue(schedule.Equals(schedule));
			Assert.AreSame(m1, schedule[0]);
			Assert.AreEqual(1, schedule.Count());			
			Assert.AreEqual(1, schedule.MovementsCount);
		}
예제 #4
0
		public void Voyage_LiveCycle_01 ()
		{
			// arrange:
			UnLocode code1 = new UnLocode("CODAA");
			ILocation loc1 = MockRepository.GenerateStrictMock<ILocation>();
			loc1.Expect(l => l.UnLocode).Return(code1).Repeat.Any();
			loc1.Expect(l => l.Name).Return("First location").Repeat.Any();
			UnLocode code2 = new UnLocode("CODAB");
			ILocation loc2 = MockRepository.GenerateStrictMock<ILocation>();
			loc2.Expect(l => l.UnLocode).Return(code2).Repeat.Any();
			loc2.Expect(l => l.Name).Return("Second location").Repeat.Any();
			UnLocode code3 = new UnLocode("CODAC");
			ILocation loc3 = MockRepository.GenerateStrictMock<ILocation>();
			loc3.Expect(l => l.UnLocode).Return(code3).Repeat.Any();
			loc3.Expect(l => l.Name).Return("Third location").Repeat.Any();
			
			ISchedule schedule = new Schedule();
			schedule = schedule.Append(new CarrierMovement(loc1, DateTime.UtcNow, loc2, DateTime.UtcNow + TimeSpan.FromDays(2)));
			schedule = schedule.Append(new CarrierMovement(loc2, DateTime.UtcNow + TimeSpan.FromDays(3), loc3, DateTime.UtcNow + TimeSpan.FromDays(4)));

			VoyageNumber number = new VoyageNumber("TESTVYG");
			VoyageEventArgs departedEvent = null;
			VoyageEventArgs stoppedEvent = null;
			
			// act:
			Challenge00.DDDSample.Voyage.Voyage voyage = new Challenge00.DDDSample.Voyage.Voyage(number, schedule);
			voyage.Departed += delegate(object sender, VoyageEventArgs e) {
				departedEvent = e;
			};
			voyage.Stopped += delegate(object sender, VoyageEventArgs e) {
				stoppedEvent = e;
			};
			
			// assert:
			Assert.AreSame(number, voyage.Number);
			Assert.IsFalse(voyage.IsMoving);
			Assert.AreEqual(code1, voyage.LastKnownLocation);
			Assert.AreEqual(code2, voyage.NextExpectedLocation);
			Assert.IsNull(departedEvent);
			Assert.IsNull(stoppedEvent);
			loc1.VerifyAllExpectations();
			loc2.VerifyAllExpectations();
			loc3.VerifyAllExpectations();
		}
예제 #5
0
		public void Append_03()
		{
			// arrange:
			UnLocode c1 = new UnLocode("LOCDA");
			UnLocode c2 = new UnLocode("LOCDA");
			
			ICarrierMovement m1 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			m1.Expect(m => m.ArrivalLocation).Return(c1).Repeat.Any();
			m1.Expect(m => m.ArrivalTime).Return(DateTime.UtcNow + new TimeSpan(48, 0, 0)).Repeat.Any();
			ICarrierMovement m2 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			m2.Expect(m => m.DepartureLocation).Return(c2).Repeat.Any();
			m2.Expect(m => m.DepartureTime).Return(DateTime.UtcNow + new TimeSpan(72, 0, 0)).Repeat.Any();
			ISchedule empty = new Schedule();
			ISchedule schedule1 = empty.Append(m1);
		
			// act:
			ISchedule schedule2 = schedule1.Append(m2);
		
			// assert:
			Assert.IsFalse(schedule2.Equals(empty));
			Assert.IsFalse(schedule2.Equals(schedule1));
			Assert.AreSame(m1, schedule2[0]);
			Assert.AreSame(m2, schedule2[1]);
			Assert.AreEqual(2, schedule2.Count());			
			Assert.AreEqual(2, schedule2.MovementsCount);
			m1.VerifyAllExpectations();
			m2.VerifyAllExpectations();
		}
예제 #6
0
		public void Equals_05()
		{
			// arrange:
			ICarrierMovement m1 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			ICarrierMovement m2 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			m1.Expect(m => m.Equals(m2)).Return(false).Repeat.AtLeastOnce();
			m2.Expect(m => m.Equals(m1)).Return(false).Repeat.AtLeastOnce();
			
			ISchedule empty = new Schedule();
			ISchedule schedule1 = empty.Append(m1);
			ISchedule schedule2 = empty.Append(m2);
		
			// act:
			bool equals1 = schedule1.Equals(schedule2);
			bool equals2 = schedule2.Equals(schedule1);
		
			// assert:
			Assert.IsFalse(equals1);
			Assert.IsFalse(equals2);
			m1.VerifyAllExpectations();
			m2.VerifyAllExpectations();
		}
예제 #7
0
		public void Equals_04()
		{
			// arrange:
			ICarrierMovement m1 = MockRepository.GenerateStrictMock<ICarrierMovement, IObject>();
			ICarrierMovement m2 = MockRepository.GenerateStrictMock<ICarrierMovement, IObject>();
			m1.Expect(m => m.Equals(m2)).Return(true).Repeat.AtLeastOnce();
			m2.Expect(m => m.Equals(m1)).Return(true).Repeat.AtLeastOnce();
			m1.Expect(m => m.GetHashCode()).Return(543210).Repeat.AtLeastOnce();
			m2.Expect(m => m.GetHashCode()).Return(543210).Repeat.AtLeastOnce();
			
			ISchedule empty = new Schedule();
			ISchedule schedule1 = empty.Append(m1);
			ISchedule schedule2 = empty.Append(m2);
		
			// act:
			bool equals1 = schedule1.Equals(schedule2);
			bool equals2 = schedule2.Equals(schedule1);
		
			// assert:
			Assert.IsTrue(equals1);
			Assert.IsTrue(equals2);
			Assert.AreEqual(schedule1.GetHashCode(), schedule2.GetHashCode());
			m1.VerifyAllExpectations();
			m2.VerifyAllExpectations();
		}
예제 #8
0
		public void Equals_03()
		{
			// arrange:
			ISchedule schedule1 = new Schedule();
			ISchedule schedule2 = new Schedule();
			
			// act:
			bool equals = schedule1.Equals((object)schedule2);
		
			// assert:
			Assert.IsTrue(equals);
			Assert.AreEqual(schedule1.GetHashCode(), schedule2.GetHashCode());
		}
예제 #9
0
		public void Equals_02()
		{
			// arrange:
			ISchedule schedule1 = new Schedule();
		
			// act:
			bool equals = schedule1.Equals(null);
		
			// assert:
			Assert.IsFalse(equals);
		}
예제 #10
0
		public void Append_05()
		{
			// arrange:
			UnLocode c1 = new UnLocode("LOCDA");
			
			ICarrierMovement m1 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			m1.Expect(m => m.ArrivalLocation).Return(c1).Repeat.Any();
			m1.Expect(m => m.ArrivalTime).Return(DateTime.UtcNow + new TimeSpan(48, 0, 0)).Repeat.Any();
			ICarrierMovement m2 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			m2.Expect(m => m.DepartureLocation).Return(c1).Repeat.Any();
			m2.Expect(m => m.DepartureTime).Return(DateTime.UtcNow).Repeat.Any();
			ISchedule empty = new Schedule();
			ISchedule schedule1 = empty.Append(m1);
		
			// act:
			schedule1.Append(m2);
		}